【问题标题】:Visual Studio 2015 - Git Fetch return The remote server returned an error: (401) UnauthorizedVisual Studio 2015 - Git Fetch 返回远程服务器返回错误:(401)未经授权
【发布时间】:2020-03-28 01:15:26
【问题描述】:

当我在 Visual Studio 2015 中使用 Team Explorer 并尝试从本地 TFS 获取 repo 时,我收到以下错误:

Error encountered while fetching: An error occurred while sending the request.

Inner Exception:
The remote server returned an error: (401) Unauthorized.

Inner Exception:
    The system cannot contact a domain controller to service the authentication request. Please try again later
Error encountered while fetching: An error occurred while sending the request.

当我使用 cmd 并执行命令时 git fetch 正在工作。

请帮助我提出解决此错误的任何建议。

【问题讨论】:

  • 你是使用 PAT token 还是 Basic Auth(username,password) 来授权 git repo/command?
  • 我正在使用 Windows 身份验证

标签: git tfs visual-studio-2015


【解决方案1】:

首先,如果问题与 Visual Studio 中的缓存凭据有关,您可以尝试缩小范围(可能您输入了错误的帐户信息、错误的密码或更改了密码)

  1. 从控制面板中删除凭据管理器中的凭据
  2. 重命名或删除 C:/Program Files(x86)/Microsoft Visual Studio/201x/Community/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer 中的 Git 目录在 Visual Studio 2015 中略有不同但相似
  3. 安装包Git Credential Manager for Windows v1.20
  4. 当 VS 要求提供凭据时插入它们

如果这仍然无法解决您的问题。那么它可能与您的网络或 TFS 服务器端设置有关。例如,您可以使用 NTML 身份验证在顶部添加协商并删除匿名访问。

更多细节请看这个类似的问题:TFS git clone using Visual Studio 2015 gives 401 unauthorized error

【讨论】:

  • 我从 凭据管理器 重置了凭据,但它仍然不起作用。问题仅存在于 Visual Studio 2015 中,因为在 Visual Studio 2017 中它可以正常工作。这也不是网络问题,因为从 cmd 我可以成功运行命令。不知何故,Visual Studio 无法通过 TFS 对我进行身份验证,因为如果我尝试在 Visual Studio 浏览器中打开 TFS,则会出现以下错误:TF400813:资源不可用于匿名访问。需要客户端身份验证。
  • @AlexandruIonciu 感谢您的快速回复。对于这种错误,您的 TFS 服务器似乎启用了匿名访问。请检查 HaBo 在这张票 stackoverflow.com/questions/44157631/… 中的回答,并在 TFS 服务器的 IIS 中禁用匿名访问,然后重试。
  • 我不允许更改 TFS 的设置,是否有任何解决方案可以强制 Visual Studio 2015 使用 Windows 身份验证?
  • @AlexandruIonciu 对此不完全确定,似乎不是。但你可以尝试clear TFS and VS cache。然后在此之后,您需要再次输入凭据,这可能会成功。如果这仍然不起作用,您将不得不联系您的 TFS 管理员以更改 TFS 服务器中的设置并重试。很抱歉给您带来不便。
  • @PatrickLu-MSFT 我已经删除了 TFS 和 VS 缓存,但它不起作用。我会尝试联系 TFS 管理员更改设置...谢谢您的宝贵时间。
猜你喜欢
  • 2012-04-29
  • 2012-02-23
  • 2016-01-17
  • 2012-03-14
  • 1970-01-01
  • 1970-01-01
  • 2012-09-19
相关资源
最近更新 更多