Git 错误致命:身份验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35834117/
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 error fatal: Authentication failed
提问by GurdeepS
I am trying to use git to push my repository to a visual studio team services project, but I get the error:
我正在尝试使用 git 将我的存储库推送到 Visual Studio 团队服务项目,但出现错误:
fatal: Authentication failed for (url of team project
I am using the cmds:
我正在使用 cmds:
git remote add origin
https://XXXXXXX.visualstudio.com/DefaultCollection/_git/project
git push -u origin -–all
Any idea of the fix for this?
知道解决这个问题吗?
Thanks!
谢谢!
回答by kxiaocai
I had a same issue recently (visual studio 2017 & Windows 10), and solved it using the following method:
我最近遇到了同样的问题(visual studio 2017 & Windows 10),并使用以下方法解决了它:
Control Panel --> Credential Manager --> Manage Windows Credentials --> Choose the entry of the git repository, and Edit the user and password.
控制面板 --> 凭据管理器 --> 管理 Windows 凭据 --> 选择 git 存储库的条目,并编辑用户和密码。
Done.
完毕。
回答by CodeWizard
If you wish to use GIT CLI and not interact with the build in GIT wrappers in Visual Studio you need to enable Alternate Authentication Credentials
如果您希望使用 GIT CLI 并且不与 Visual Studio 中 GIT 包装器中的构建进行交互,则需要启用备用身份验证凭据
How?
如何?
Open your account (VS Online account)
-> click on your name on the top right
-> My Profile
-> Credentials.
and set it up.
并设置它。
回答by Anusha M Shetty
I have faced the same issue. The error output window looks like this:
我遇到了同样的问题。错误输出窗口如下所示:
Following the steps resolved the issue:
按照以下步骤解决了问题:
- Go to Control Panel --> Credential Manager --> Windows Credentials
Below Generic Credential, choose an entry of the git & update password.
Password should be same as windows(system) login password.
- 转到控制面板 --> 凭据管理器 --> Windows 凭据
在 Generic Credential 下,选择一个 git 条目并更新密码。
密码应与windows(系统)登录密码相同。
回答by Giulio Vian
The best option today is to install https://github.com/Microsoft/Git-Credential-Manager-for-Windowsthat supports VSO, GitHub and is improving every month.
今天最好的选择是安装https://github.com/Microsoft/Git-Credential-Manager-for-Windows支持 VSO、GitHub 并且每个月都在改进。
回答by Max
With VSTS the url is, When you copy git clone url from vsts you always get
使用 VSTS,url 是,当你从 vsts 复制 git clone url 时,你总是得到
https://orgname@dev.azure.com/org/project/_git/repo
https:// orgname@dev.azure.com/org/project/_git/repo
Replace orgname@with your alternate usernamethat you would have created in VSTS -> profile -> Security.
将orgname@替换为您在VSTS -> 配置文件 -> 安全中创建的备用用户名。
final git url -
最终的 git 网址 -
https://alternateusername@dev.azure.com/org/project/_git/repo
https:// alternateusername@dev.azure.com/org/project/_git/repo
回答by Web Application Developer
I had the same problem, I tried to update my password using windows credential manager, it still didn't fix the issue
我遇到了同样的问题,我尝试使用 Windows 凭据管理器更新我的密码,它仍然没有解决问题
Control Panel --> Credential Manager --> Manage Windows Credentials --> Choose the entry of the git repository, and Edit the user and password.
控制面板 --> 凭据管理器 --> 管理 Windows 凭据 --> 选择 git 存储库的条目,并编辑用户和密码。
I then deleted all the git related entry in credentials manager and then tried to use Git using visual studio, this time it prompted for new credentials
然后我删除了凭据管理器中所有与 git 相关的条目,然后尝试使用 Visual Studio 使用 Git,这次它提示输入新凭据
回答by Longfei Wu
Delete '.git/config' and try again.Attention this will may reset some git settings too!
删除“.git/config”并重试。注意这也可能会重置一些 git 设置!
I've tried alternative credentials and Personal Access Token for many times with right credential and it kept telling me "fatal: Authentication failed".
我已经多次尝试使用正确的凭据使用替代凭据和个人访问令牌,它一直告诉我“致命:身份验证失败”。
Finally, I found there is a file named ".git/config" located at the root of my Repo. I deleted this file and type in my credentials again, it worked.
最后,我发现在我的 Repo 的根目录中有一个名为“.git/config”的文件。我删除了这个文件并再次输入我的凭据,它起作用了。
回答by Mr Slim
I suddenly started receiving this error when attempting to push changes from VS2017 to a VSTS Git repository. This functionality had worked the day before.
尝试将更改从 VS2017 推送到 VSTS Git 存储库时,我突然开始收到此错误。这个功能在前一天已经起作用了。
I checked my git.log file and saw a different exception :-
我检查了我的 git.log 文件并看到了一个不同的异常:-
19:43:57.116665 ...zureAuthority.cs:184 trace: [ValidateCredentials] server returned: 'Unable to connect to the remote server.
19:43:57.116665 ...zureAuthority.cs:184 跟踪:[ValidateCredentials] 服务器返回:“无法连接到远程服务器。
I downloaded the latest Git CredentialManager source from Gits Credential Manager repoand debugged it.
我从Gits Credential Manager repo下载了最新的 Git CredentialManager 源代码并对其进行了调试。
Once authenticated, the following exception occurred :-
一旦通过身份验证,就会发生以下异常:-
No connection could be made because the target machine actively refused it 127.0.0.1:8888
无法建立连接,因为目标机器主动拒绝它 127.0.0.1:8888
I then realised that I had recently setup Fiddler to act as a proxy for all services as per the article capturing-traffic-from-.net-services-with-fiddler
然后我意识到我最近设置了 Fiddler 作为所有服务的代理,如capture-traffic-from-.net-services-with-fiddler 文章所述
Once I ran Fiddler, I was able to successfully connect.
一旦我运行 Fiddler,我就能够成功连接。
回答by Antonio Buonaiuto
My solution was a little bit different and faster :)
我的解决方案有点不同,而且速度更快:)
- Go to Windows Credentials (Start-> Windows Credentials) and remove credentials for your repository (they starts with git:xxx)
Go to VSCode and in Terminal write:
config credential.helper wincred
Go to Visual Studio (no VSCode) and make a git pull. A popup will show asking for credentials. Put your credentials for the repo
Go to VSCode and make a git pull. Credentials were automatically fetched from wincred store
- 转到 Windows 凭据(开始-> Windows 凭据)并删除存储库的凭据(它们以 git:xxx 开头)
转到 VSCode 并在终端中写入:
配置 credential.helper wincred
转到 Visual Studio(无 VSCode)并进行 git pull。将显示一个弹出窗口,要求提供凭据。将您的凭据放在回购协议中
转到 VSCode 并进行 git pull。凭据是从 wincred 商店自动获取的
Credentials are automatically created and stored in wincredentials, so the next time you cannot be asked for credentials. (also a Personal Access Token will be provided from visualstudio.com if you are using DevOps hosted git repo).
凭据会自动创建并存储在 wincredentials 中,因此下次不会要求您提供凭据。(如果您使用 DevOps 托管的 git 存储库,还将从 visualstudio.com 提供个人访问令牌)。
回答by Arsen Khachaturyan
I've tried lots of options, but the one that worked for me was to:
我尝试了很多选择,但对我有用的是:
Download the Git Password Manager from its Releasessection
Try to do simple
git fetch
which will automatically bring the window(alternate to default windows one for example) and ask to enter username and password but with more elegant way than the standard one.
从其发布部分 下载 Git 密码管理器
尝试做简单的事情
git fetch
,它会自动打开窗口(例如,替代默认的窗口)并要求输入用户名和密码,但比标准的方式更优雅。
After correctly entering the credentials it worked, though I was getting an error before.
正确输入凭据后,它起作用了,尽管我之前遇到了错误。
P.S. If you are getting "Wrong Credentials" kind of errors always check if the repository usernameand passwordare correct. If you hesitate just reset the password and try to use the same one in the Git Password manager window.
PS如果您收到“错误的凭据”类型的错误,请始终检查存储库用户名和密码是否正确。如果您犹豫,只需重置密码并尝试在 Git 密码管理器窗口中使用相同的密码。