Git推送导致“身份验证失败” [英] Git push results in "Authentication Failed"
问题描述
我一直在使用Github,而且我对 git add
, git commit
都没有问题,和 git push
到目前为止没有问题。突然间我有一个错误,说:
致命:身份验证失败
在终端中,我克隆了一个存储库,处理一个文件,然后使用 git add
将该文件添加到提交日志中,当我做了 git commit
,它工作正常。最后, git push
要求输入用户名和密码。我把这些放在正确的位置,每次我这样做时,都会出现同样的错误。
有谁知道这个问题的原因是什么以及我可以如何解决它是什么?
.git / config
的内容为:
[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 / *
[branchmaster]
remote = origin
merge = refs / heads / master
[user]
name = #####
email = ############
如果您在Github帐户中启用双因素身份验证,您的
将无法使用帐户密码通过HTTPS推送。相反,
您需要生成个人访问令牌。这可以在Github帐户的
应用程序设置中完成。使用此令牌作为您的
密码应允许您通过HTTPS推送到远程存储库。
像往常一样使用您的用户名。
https://help.github.com/articles/https-cloning-errors#provide-access-token-if-2fa-enabled
如果设置为https,您可能还需要更新存储库的来源:
git remote -v
git remote remove origin
git remote add origin git@github.com:user / repo.git
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
这篇关于Git推送导致“身份验证失败”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!