Pushing to Git returning Error Code 403 fatal: HTTP request failed

后端 未结 30 1168
轻奢々
轻奢々 2020-11-22 04:52

I was able to clone a copy of this repo over HTTPS authenticated. I\'ve made some commits and want to push back out to the GitHub server. Using Cygwin on Windows 7 x64.

相关标签:
30条回答
  • 2020-11-22 05:01

    To definitely be able to login using https protocol, you should first set your authentication credential to the git Remote URI:

    git remote set-url origin https://yourusername@github.com/user/repo.git
    

    Then you'll be asked for a password when trying to git push.

    In fact, this is on the http authentication format. You could set a password too:

    https://youruser:password@github.com/user/repo.git
    

    You should be aware that if you do this, your github password will be stored in plaintext in your .git directory, which is obviously undesirable.

    0 讨论(0)
  • 2020-11-22 05:01

    One small addition to Sean's answer.

    Instead of editing .git/config file manually, you can use git remote set-url command.

    In your case it should be:

    git remote set-url origin ssh://git@github.com/derekerdmann/lunch_call.git
    

    I find it easier and cleaner, than messing around with dot-files.

    • help.github.com: Changing a remote's URL
    0 讨论(0)
  • 2020-11-22 05:03

    A 403 code is "Forbidden". The server saw your request and refused it. Do you have permission to push to that repository?

    0 讨论(0)
  • 2020-11-22 05:04

    Same error and resolution on Mac OS X.

    Everything was working fine till I created a new account on GitHub and tried to push

    $ git push -u origin master
    

    And got the error:

    remote: Permission to NEWUSER/NEWREPO.git denied to OLDUSER. fatal: unable to access ‘https://github.com/NEWUSER/NEWREPO.git/': The requested URL returned error: 403

    It should have fixed by setting the user.name either for global or current repo

    $ git config –-global user.name NEWUSER
    $ git config user.name NEWUSER
    

    But it didn’t.

    I got it fixed by deleting the OLDUSER associated with GitHub from Keychain Access app under Passwords section. Then the push command went successful.

    $ git push -u origin master
    

    reference

    0 讨论(0)
  • 2020-11-22 05:04

    For those having permission denied 403 error while using ssh(according to Xiao) or http urls try these commands

    >git config --global --unset-all credential.helper
    
    >git config --unset-all credential.helper
    

    with administrator rights

    >git config --system --unset-all credential.helper
    
    0 讨论(0)
  • 2020-11-22 05:05

    I think @deepwaters got the answer correct for older versions. The HTTPS URL needs to have the username. I had git 1.7.0.4 and git push origin master wouldn't even ask for a password till I added it.

    0 讨论(0)
提交回复
热议问题