使用Bitbucket的Visual Studio 2017,禁用终端提示

43

Visual Studio停止向Bitbucket发送我的提交,出现以下错误:

克隆远程存储库时遇到错误:Git发生致命错误。HttpRequestException发生了。提交请求时发生错误。无法派生

C / Program Files (x86) / Microsoft Visual Studio / 2017 / Community / Common7 / IDE / CommonExtensions / Microsoft / TeamFoundation / Team Explorer / Git / mingw32 / libexec / git-core / git-askpass.exe: 没有 这样的文件或目录

无法读取“https://gustavobedsamarpes@bitbucket.org”的密码:终端提示被禁用。在尝试克隆仓库或提交时会出现此错误。


Git插件以前是否正常工作而没有错误?尝试直接从命令行使用Git。如果在那里也出现问题,那么我们就知道这不仅仅是一个IDE的问题。 - Tim Biegeleisen
2
尝试将仓库链接格式从“https://username@bitbucket.org”更改为“https://username:password@bitbucket.org”。这应该可以工作。 - CodeMind
将存储库链接更改为包括您的密码会起作用。但是,现在您的密码以明文形式存储在git配置文件中。这不是一个好主意。 - Don Shrout
5个回答

93

我也遇到了同样的问题,我在这里找到了一个解决方法:

https://github.com/github/VisualStudio/issues/949

以下是修复步骤: 看起来 Visual Studio 2017 中捆绑的 Git-Credential-Manager-for-Windows/ 并不是最新版本。下载最新版本并将其放在 Visual Studio 2017 文件之上可以解决问题。

  1. https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.17.0下载zip文件 gcmw-v1.17.0.zip
  2. 导航到 C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\(或者您所在的缺失 'git-askpass.exe' 的目录)。
  3. 复制 git-core 文件夹并将其重命名为backup或其他名称
  4. 用 zip 文件中的文件覆盖新 git-core 文件夹的内容,在提示时进行覆盖

6
我使用 "Professional" 替换路径 C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core,成功运行。 - Dan Beaulieu
7
在我使用bitbucket.org时也起作用了,但需要额外添加一步 - 我必须将远程设置的URL从https://login@bitbucket.org/myrepo/myproject.git更改为https://bitbucket.org/myrepo/myproject.git。 - TH Todorov
9
请确保你执行的是压缩文件而不是可执行文件(.exe)。 - Demodave
3
在我的电脑上,使用 Visual Studio 2017 Community 和 Bitbucket 进行了工作。路径为 C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core - palehorse
6
gcmw-v1.17.0.zip仍然存在漏洞,新版本v1.16.3解决了这个问题。v1.6.3更新日志:修复了与Bitbucket多因素认证相关的问题 https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.16.3 - whizzzkey
显示剩余15条评论

8
我刚刚有这种经历。我尝试登录Bitbucket,结果惊讶地发现它显示“无法使用用户名登录,请使用电子邮件”。然后我用我的电子邮件登录,找到了我的Bitbucket设置,并发现我可以生成密码...
1. 进入设置页面 2. 应用程序密码 3. 创建应用程序密码 4. 使用该密码登录,而不是您的真实密码。
请参照下面的截图: enter image description here

已经适用于VS2022!谢谢。 - Stefano Altieri

7

更好的解决方案。

在与维护Visual Studio中团队资源管理器的Chad Boles进行交谈后,我们找到了另一种选项。这比覆盖Visual Studio安装中的文件更可取,因为这可能会破坏未来的更新并且会在未来引起难以调试的问题。

诀窍是,在Visual Studio实际上使用Git Credential Manager for Windows 1.18.4或更高版本之前(应该在Visual Studio 2019预览版4.0或更高版本之后),要在Git全局配置中配置Git凭据管理器的特定安装位置:

  1. Install the latest version of GCMW-1.xx.x.exe in your system and/or update to the latest version of Git for Windows which should include GCM.
  2. Update your global git config to point to a specific implementation of the Git credential Manager:

    c:\>git config --global --edit
    

    Update the [credential] section to read:

    [credential]
        helper = C:\\\\Program\\ Files\\\\Git\\\\mingw64\\\\libexec\\\\git-core\\\\git-credential-manager.exe
    

    Ensure the path points to where the latest Git Credential Manager can be found on your system. Mind all of the escapes needed to make paths work in the global git config.

无需更改配置的替代方法

另一种选择是安装最新版本的Git for Windows(已经包含了Git凭据管理器 for Windows 1.18.4),并从命令行执行初始克隆和身份验证。这将在Windows凭据存储中存储凭据,之后Visual Studio将会轻松获取它们。


1
安装最新的GCM和GFW Windows有所帮助。但为了解决实际问题,我不得不将我的repo重新克隆到一个新文件夹中以修复凭据问题。谢谢! - samneric
1
可能是远程URL出了问题。 - jessehouwing
我认为你是正确的 - 回顾过去,我认为这是一个延迟问题,因为微软将存储库从vsts*重命名为dev.azure.com。 - samneric

1
除了Ecd的答案之外(我还不能评论),当你的密码包含“@”符号(或任何用于url的符号)时,你需要转义该字符,因为它会通过url编码导致“无法解析主机”的结果。对于“@”符号的情况,使用“%40”。请保留HTML标签。

1

我在Visual Studio 2019中解决了这个问题。

在工具->Nuget包管理器->包管理器控制台中

此命令将为您更新GitForWindows版本(以及Git凭据管理器)。

Install-Package GitForWindows -Version 2.23.0

参考链接:https://www.nuget.org/packages/GitForWindows/


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接