Git 推送导致“身份验证失败”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17659206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git push results in "Authentication Failed"
提问by zkirkland
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:
我一直在使用Github上一小会儿,我一直罚款git add
,git commit
以及git push
到目前为止,没有任何问题。突然我有一个错误说:
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.
在终端中,我克隆了一个存储库,处理了一个文件,然后我曾经git add
将该文件添加到提交日志中,当我这样做时git commit
,它运行良好。最后,git push
询问用户名和密码。我把它们正确地放进去,每次我这样做时,它都会说同样的错误。
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 = ############
回答by rc0r
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.
如果您在 Github 帐户中启用了双因素身份验证,您将无法使用您的帐户密码通过 HTTPS 进行推送。相反,您需要生成个人访问令牌。这可以在您的 Github 帐户的应用程序设置中完成。使用此令牌作为您的密码应该允许您通过 HTTPS 推送到您的远程存储库。像往常一样使用您的用户名。
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 [email protected]:user/repo.git
回答by Pradeep
Try the following steps to Edit or Remove the saved credentials:
尝试以下步骤来编辑或删除保存的凭据:
- Click Start
- Type: Credential Manager (On Windows 10, this is under "Start->Settings". Then search for "Credential Manager")
- See the
Windows Credentials Manager
shortcut and double-click it to open the application. - Once the app is open, click on the
Windows Credentials
tab. - Locate the credentials that you want to remove/update, they will start with "git:" and might begin with "ada:"
- Click on the credential entry, it will open a details view of the entry.
- Click Edit or Remove as required and confirm.
- Wash, rinse, repeat as necessary.
- 点击开始
- 类型:凭据管理器(在 Windows 10 上,这是在“开始->设置”下。然后搜索“凭据管理器”)
- 查看
Windows Credentials Manager
快捷方式并双击它以打开应用程序。 - 打开应用程序后,单击
Windows Credentials
选项卡。 - 找到您要删除/更新的凭据,它们将以“git:”开头,并可能以“ada:”开头
- 单击凭证条目,它将打开条目的详细信息视图。
- 根据需要单击“编辑”或“删除”并确认。
- 清洗,冲洗,必要时重复。
回答by Utukku
This worked for me, and it also remembers my credentials:
这对我有用,它也记住了我的凭据:
Run gitbash
Point to the repo directory
Run
git config --global credential.helper wincred
运行 gitbash
指向repo目录
跑
git config --global credential.helper wincred
回答by Users9949
May you have changed password recently for you git account
You could try the git push
with -u
option
您最近是否为您的 git 帐户更改了密码您可以尝试使用git push
with-u
选项
git push -u origin branch_name_that_you_want_to_push
After executing above command it will ask for password provide your updated password
执行上述命令后,它会要求输入密码提供您更新后的密码
Hope it may help you
希望它可以帮助你
回答by VonC
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.
然后,如果它以前可以工作,并且没有要求您提供用户名,那一定是因为您已将凭据(登录名/密码)存储在$HOME/.netrc
文件中,如此处所述。您可以仔细检查这些设置,并确保您的代理(如果有)没有更改。
If that still doesn't work, you can switch to an ssh url:
如果这仍然不起作用,您可以切换到 ssh 网址:
git remote set-url origin [email protected]:zkirkland/Random-Python-Tests.git
But that means you have published your ssh public key in your Account settings.
但这意味着您已经在您的帐户设置中发布了您的 ssh 公钥。
回答by Atif AbbAsi
It happens if you change your login or password of git service account (Git). You need to change it in Windows Credentials Managertoo. type "Credential Manager" in Windows Search menu open it.
如果您更改了 git 服务帐户 (Git) 的登录名或密码,就会发生这种情况。您也需要在Windows 凭据管理器中更改它。在 Windows 搜索菜单中输入“凭据管理器”打开它。
Windows Credentials Manager->Windows Credential and under Generic Credentialsedit your git password.
Windows Credentials Manager->Windows Credential 并在 Generic Credentials 下编辑您的 git 密码。
回答by Jems
Basically my credential was expired, and I was facing above issue.
基本上我的凭据已过期,我正面临上述问题。
Following 2 command helped me:
以下 2 个命令帮助了我:
git config --global --unset credential.helper
git config credential.helper store
It will asks you for credentials next time when you try to push.
下次尝试推送时,它会要求您提供凭据。
Follow below guidelines for more details for secured and unsecured storage of user name and passwords:
有关安全和不安全的用户名和密码存储的更多详细信息,请遵循以下指南:
https://git-scm.com/docs/git-credential-store
https://git-scm.com/docs/git-credential-store
回答by Hoque MD Zahidul
回答by Electo
I think that for some reason GitHub is expecting the URL to NOT have subdomain www. When I use (for example)
我认为出于某种原因,GitHub 期望 URL 没有子域 www。当我使用(例如)
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。
回答by Charming ZooZoo
Hi,I was getting the same error i tried all the solutions whichever mentioned in this page, but didn't work. Finally, i found the solution, So thought of posting it. Please correct me if i am wrong anywhere. These kinds of error comes if sometimes your system password has changed recently anytime. It will try to validate from old password. So, Follow these steps:
嗨,我遇到了同样的错误,我尝试了本页中提到的所有解决方案,但没有奏效。最后,我找到了解决方案,所以想到发布它。如果我在任何地方错了,请纠正我。如果您的系统密码最近随时更改,就会出现此类错误。它将尝试从旧密码进行验证。因此,请按照以下步骤操作:
- Go to control panel
- Click on User accounts
- Under Credentials manager
- Go to Manage windows credentials
- Go to Generic credentials
- Expand git server tab
click on Remove from vault
- Also you can click edit and change your password stored here directly.
- 进入控制面板
- 点击用户账户
- 在凭据管理器下
- 转到管理 Windows 凭据
- 转到通用凭据
- 展开 git 服务器选项卡
单击从保管库中删除
- 您也可以单击编辑并直接更改此处存储的密码。