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. I have to hit the 'X' to close 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.
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). It often happens after setting up VS on a new machine.
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 (i.e. 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).
The problem comes when you have not visited the repo's git server with any of PuTTY's programs before. 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.
To fix it, just visit the server once from the command line, e.g 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.
After doing that once, it will work fine from then on with PuTTY's pageant/plink integration, including in Visual Studio.