Git push results in "Authentication Failed"

I have been using Github for a little while and I have been fine with git add , git commit , and git push so far with no problems. Suddenly I am having an error that says:

fatal: Authentication Failed

In the terminal I cloned a repository, worked on a file and then I used git add to add the file to the commit log and when I did git commit , it worked fine. Finally, git push asks for username and password. I put those in correctly and every time I do this, it says the same error.

Does anyone have any idea what the cause of this problem is and how I can fix it?

The contents of .git/config are:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = http://www.github.com/######/Random-Python-Tests
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        name = #####
        email = ############

If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

https://help.github.com/articles/https-cloning-errors#provide-access-token-if-2fa-enabled

You may also need to update the origin for your repository if set to https:

git remote -v 
git remote remove origin 
git remote add origin git@github.com:user/repo.git  

First, you can make sure to use the proper url:

git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git

Then, if it was working before, and if it wasn't asking for you username, it must be because you had stored your credentials (login/password) in a $HOME/.netrc file, as explained here. You can double-check those settings, and make sure that your proxy, if you have one, hasn't changed.

If that still doesn't work, you can switch to an ssh url:

git remote set-url origin git@github.com:zkirkland/Random-Python-Tests.git

But that means you have published your ssh public key in your Account settings.


This worked for me, and it also remembers my credentials:

  • Run gitbash

  • Point to the repo directory

  • Run git config --global credential.helper wincred

  • 链接地址: http://www.djcxy.com/p/22068.html

    上一篇: 在Github推送新代码的问题

    下一篇: Git推送导致“身份验证失败”