0

If i use command

git push 

It says fatal: unable to access 'http://***.git The requested URL returned error: 403 If i add sudo sudo git push it works fine. Where should i add permissions?

I tried

sudo find /var/www/.git -type d -exec chmod 0777 {} +

And

sudo find /var/www/.git -type f -exec chmod 0777 {} +

But it only helps me to commit from my user

Pashuk xCode
  • 81
  • 1
  • 8

2 Answers2

1

So my ip changed(local) when i get new computer. Previously in our company was corporate proxy. So i entered:

export https_proxy=""
export http_proxy=""

And add in your local repository folder

 sudo chown -R YourUserName .git/ 

if you need to clone project in folders such var from user use

 sudo find /var/ -type d -exec chmod 0777 {} +
 sudo find /var/ -type f -exec chmod 0777 {} + 
Pashuk xCode
  • 81
  • 1
  • 8
0

403 is a permission error returned by the server, not your local workstation, so no amount of chmod 777 will change that.

Check your credential helper: git config credential.helper: chances you have one defined when you type that command as you (not as root with sudo)

It could be gnome-keyring (now obsolete) or git-credential-libsecret. Or store.

Try first, for testing, to unset it, then push again: it should query for your credentials (GitHub username/password). Check if the push succeeds.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yeap i agree with you. But it says 403 error. Look like a bug. When i change 777 it allow me to commit. Push allow with sudo. – Pashuk xCode Nov 08 '18 at 06:05
  • @PashukxCode Is the remote server one you control, or a remote Git repos hosting server like github.com or gitlab.com? – VonC Nov 08 '18 at 07:48
  • Nope...I think may be i make rsa key from sudo...for http...or something like that. – Pashuk xCode Nov 09 '18 at 00:22
  • It happens when i change my computer to new one. And save Hard disk. – Pashuk xCode Nov 09 '18 at 00:23
  • @PashukxCode Yes, it is important to *not* use sudo, but only your local Linux account, when working with Git, in order to use your associate credentials (like a ~/.ssh/id_rsa(.pub) key). – VonC Nov 09 '18 at 05:32