简体   繁体   English

Visual Studio 2017/2019/2022 git 同步/拉/推/取操作卡住,无法停止

[英]Visual Studio 2017/2019/2022 git sync/pull/push/fetch operation stuck, and cannot be stopped

I initiate sync, fetch, pull or push from the 'Git Changes' tab in Visual Studio, but the operation just hangs, with no option to stop it.我从 Visual Studio 中的“Git Changes”选项卡启动同步、获取、拉取或推送,但操作只是挂起,没有停止它的选项。 I have to hit the 'X' to close Visual Studio.我必须点击“X”才能关闭 Visual Studio。

If the operation is a sync it opens a modal dialog over everything else, so the hang is even worse and I have to force quit Visual Studio from Task Manager.如果操作是同步操作,它会在其他所有内容上打开一个模式对话框,因此挂起更糟,我必须从任务管理器中强制退出 Visual Studio。

This applies to all versions of Visual Studio with git integration (I was recently seeing it in VS 2019 and VS 2022 preview, but have seen it before in VS 2017).这适用于具有 git 集成的所有 Visual Studio 版本(我最近在 VS 2019 和 VS 2022 预览版中看到它,但之前在 VS 2017 中看到过它)。 It often happens after setting up VS on a new machine.它通常发生在在新机器上设置 VS 之后。

There may be other reasons for this as well, but for me it is because I am using PuTTY's Pageant program for integrated git authentication (ie I start pageant.exe with my private key, and I have added GIT_SSH=C:\Program Files\PuTTY\plink.exe to my environment variables, so that Visual Studio, Git for Windows, etc. can use it to authenticate).这也可能有其他原因,但对我来说,这是因为我正在使用 PuTTY 的 Pageant 程序进行集成 git 身份验证(即我用我的私钥启动 pageant.exe,并且我添加了GIT_SSH=C:\Program Files\PuTTY\plink.exe到我的环境变量中,以便Visual Studio、Git for Windows 等可以用它来认证)。

The problem comes when you have not visited the repo's git server with any of PuTTY's programs before.当您之前没有使用 PuTTY 的任何程序访问过 repo 的 git 服务器时,就会出现问题。 Even if Pageant is started with a valid key, the first time you visit the server you still need to add the server's key to PuTTY's storage.即使 Pageant 是使用有效的密钥启动的,当您第一次访问服务器时,您仍然需要将服务器的密钥添加到 PuTTY 的存储中。

To fix it, just visit the server once from the command line, eg putty git@bitbucket.org or putty git@github.com (it depends on what the remote is, as shown by git remote -v ), then a PuTTY Security Alert window pops up and you need to click Accept for the server's certificate.要修复它,只需从命令行访问服务器一次,例如putty git@bitbucket.orgputty git@github.com (这取决于远程是什么,如git remote -v所示),然后是 PuTTY Security弹出警报 window,您需要单击接受服务器的证书。

After doing that once, it will work fine from then on with PuTTY's pageant/plink integration, including in Visual Studio.这样做一次之后,它将与 PuTTY 的 pageant/plink 集成(包括在 Visual Studio 中)一起正常工作。

I had similar issues with VS 2022 Git Manage Branched was stuck after pull/push.我与 VS 2022 Git 管理分支在拉/推后卡住了类似的问题。 luckily, everything was working OK using github desktop, so I used it to sync my work.幸运的是,使用 github 桌面一切正常,所以我用它来同步我的工作。 After few days of frustrations the issue was fixed after I updated git version to the latest (updated from 2.20 to 2.36)经过几天的挫折后,我将 git 版本更新到最新版本(从 2.20 更新到 2.36)后问题得到了解决

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM