使用 Git 克隆 TFS 存储库时身份验证失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39999361/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:21:02  来源:igfitidea点击:

Authentication Fails When Cloning TFS repo with Git

gittfsvisual-studio-code

提问by Bassie

I have always created local repositories using this command:

我一直使用以下命令创建本地存储库:

git clone http://TFSServer:8080/tfs/Scripts/_git/ProjectName

However, when I do it at the moment I get this message:

但是,当我现在这样做时,我收到了以下消息:

Cloning into 'ProjectName' ...

fatal: Authentication failed for 'http://TFSServer:8080/tfs/Scripts/_git/ProjectName/'

克隆到“项目名称”...

致命:“ http://TFSServer:8080/tfs/Scripts/_git/ProjectName/”的身份验证失败



When starting up Visual Studio Code I see this error:

启动 Visual Studio Code 时,我看到此错误:

unable to get local issuer certificate

无法获得本地发行人证书

and when trying to push to TFS from VSCode (which I have always been able to do in the past), I see this error:

当尝试从 VSCode 推送到 TFS 时(我过去一直能够这样做),我看到了这个错误:

Authentication failed on the git remote

git 远程身份验证失败



After checking the repo permissions, I can see that I have full permissions:

检查 repo 权限后,我可以看到我拥有完全权限:

enter image description here

在此处输入图片说明

回答by Bassie

It turns out that this only started happening after I needed to change Windows logon password.

事实证明,这只是在我需要更改 Windows 登录密码后才开始发生。

The password was updated locally and on the TFS server, but not in the cached credentials for git.

密码已在本地和 TFS 服务器上更新,但未在 git 的缓存凭据中更新。

Fix

使固定

Control Panel-> Credential Manager-> Generic Credentials

Control Panel-> Credential Manager->Generic Credentials

Then update the password for git:http://ServerName:1234/

然后更新密码 git:http://ServerName:1234/

Now I can successfully access the repo from command line and VS Code.

现在我可以从命令行和 VS Code 成功访问 repo。

回答by Cece Dong - MSFT

Please check the Git repository 'ProjectName' permissions to see whether you have the Readpermission, or grant your account the Readpermssion:

请检查 Git 存储库的“ProjectName”权限以查看您是否具有读取权限,或授予您的帐户读取权限:

enter image description here

在此处输入图片说明

回答by Mike

In my case the issue was resolved changing settings in Visual Studio. I got the instructions from this post on Microsoft's Developer Community.

在我的情况下,问题已解决,更改 Visual Studio 中的设置。我从 Microsoft 开发人员社区上的这篇文章中得到了说明。

Git Clone from TFS: Authentication error

来自 TFS 的 Git 克隆:身份验证错误

Depending on what kind of secure channel are you using to connect to your repo the solution for this issue could be different. In my case I'm using OpenSSL and the steps to fix the problem are ase follows:

根据您使用哪种安全通道连接到您的存储库,此问题的解决方案可能会有所不同。就我而言,我使用的是 OpenSSL,解决问题的步骤如下:

  1. Open Visual Studio.
  2. Click on Team Explorer > Settings > Global Settings
  3. Change the Cryptographic network provider to OpenSSL.
  1. 打开 Visual Studio。
  2. 单击团队资源管理器 > 设置 > 全局设置
  3. 将加密网络提供程序更改为 OpenSSL。

回答by Daniel Mann

I can almost guarantee you that the URL you're using is wrong.

我几乎可以向您保证,您使用的 URL 是错误的。

It should typically be: git clone http://<tfs uri>/tfs/<team project collection name>/<team project name>/_git/<repo name>

它通常应该是: git clone http://<tfs uri>/tfs/<team project collection name>/<team project name>/_git/<repo name>