赞
踩
本文翻译自: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. 我已经使用Github一段时间了,我一直很好用git add
, git commit
和git push
到目前为止没有任何问题。 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. 在终端我克隆了一个存储库,处理了一个文件,然后我使用git add
将文件git add
到提交日志中,当我执行git commit
,它运行正常。 Finally, git push
asks for username and password. 最后, git push
要求输入用户名和密码。 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: .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/*
- [branch "master"]
- remote = origin
- merge = refs/heads/master
- [user]
- name = #####
- email = ############
参考:https://stackoom.com/question/1C5xu/Git推送导致-身份验证失败
First, you can make sure to use the proper url: 首先,您可以确保使用正确的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 . 然后,如果它之前正在工作,并且如果它没有要求您使用用户名,则必须是因为您已将凭证(登录/密码)存储在$HOME/.netrc
文件中,如此处所述 。 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: 如果仍然无效,您可以切换到ssh网址:
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 . 但这意味着您已在帐户设置中发布了ssh公钥。
I had the same problem. 我有同样的问题。 I set url in that way: 我以这种方式设置url:
git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git
I also removed from config file this entry: askpass = /bin/echo
. 我还从配置文件中删除了这个条目: askpass = /bin/echo
。 Then "git push" asked me for username and password and this time it worked. 然后“git push”问我用户名和密码,这次它有效。
If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. 如果您在Github帐户中启用了双因素身份验证,则无法使用您的帐户密码通过HTTPS推送。 Instead you need to generate a personal access token. 相反,您需要生成个人访问令牌。 This can be done in the application settings of your Github account. 这可以在您的Github帐户的应用程序设置中完成。 Using this token as your password should allow you to push to your remote repository via HTTPS. 使用此令牌作为密码应该允许您通过HTTPS推送到远程存储库。 Use your username as usual. 照常使用您的用户名。
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
You may also need to update the origin for your repository if set to https: 如果设置为https,您可能还需要更新存储库的源:
- git remote -v
- git remote remove origin
- git remote add origin git@github.com:user/repo.git
I think that for some reason GitHub is expecting the URL to NOT have subdomain www. 我认为由于某种原因,GitHub期望URL不具有子域名www。 When I use (for example) 当我使用(例如)
git remote set-url origin https://www.github.com/name/repo.git
it gives the following messages: 它给出了以下消息:
- remote: Anonymous access to name/repo.git denied
- fatal: Authentication failed for https://www.github.com/name/repo.git
However, if I use 但是,如果我使用
git remote set-url origin https://github.com/name/repo.git
it works perfectly fine. 它工作得很好。 Doesn't make too much sense to me... but I guess remember not to put www in the remote URL for GitHub repositories. 对我来说没有多大意义......但我想记得不要把www放在GitHub存储库的远程URL中。
Also notice the clone URLs provided on the GitHub repository webpage doesn't include the www. 另请注意,GitHub存储库网页上提供的克隆URL不包含www。
I'm not really sure what I did to get this error, but doing: 我不确定我做了什么来得到这个错误,但做的是:
git remote set-url origin https://...
didn't work for me. 不适合我。 However: 然而:
git remote set-url origin git@bitbucket.org:user/repo
somehow worked. 不知何故工作。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。