I can push to Github using Git at the command line with no problems. Now I'm trying to use Visual Studio 2019 to push to Github. I opened the Git > Manage Branches window in Visual Studio and clicked on the Push link on my current commit. I get the following error:
Opening repositories:
C:\Users\brubin\source\repos\MyRepo
Commit 6da600da created locally in repository C:\Users\brubin\source\repos\MyRepo
Pushing master
Pushing to github.com:MyUser/MyRepo.git
Error: cannot spawn C:/WINDOWS/System32/OpenSSH/ssh.exe: No such file or directory
Error encountered while pushing to the remote repository: Git failed with a fatal error.
unable to fork
Failed to push to the remote repository. See the Output window for more details.
ssh.exe
does exist at that path. I've tried running Visual Studio as administrator as well.
In the Push view in Team Explorer, select the Publish Git Repo button under Push to Visual Studio Team Services. Verify your email and select your account in the Team Services Domain drop-down. Enter your repository name and select Publish repository.
In the Visual Studio IDE, select the Git menu, select Local Repositories, and then select Open Local Repository.
core.sshCommand
settingVisual Studio 2019 will try the core.sshCommand
setting. This defaulted to the 32-bit ssh client in C:\Windows\System32\
for me as well.
I had success changing the configuration as shown below. Open a command prompt and change the path to your ssh executable of choice - in my case it is the version from Git for Windows.
git config --global core.sshCommand "\"C:\Program Files\Git\usr\bin\ssh.exe\""
Yes, including the "
and then escaped \"
, otherwise it will misread the setting because of the space and the error message likely reads C:\Program cannot be found or similar.
The setting can then be found in your home directory in the .gitconfig
file.
I think I've managed to resolve the issue here while still using OpenSSH
. Built-in Windows 10 OpenSSH
is a 64-bit program. But the Git, that is running from within Visual Studio is 32-bit. Visual Studio uses the one in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin"
(adjust the path accordingly to your VS version).
The thing is, that Windows uses virtual folders to prevent 32-bit programs from accessing 64-bit libraries. So if 32-bit app tries to access System32
folder, it is being redirected to SysWOW64
instead. And there is no OpenSSH
there. You can simulate that by trying to access OpenSSH
folder from 32-bit
powershell window:
> cd C:\Windows\System32\OpenSSH\
What you want to do is to set GIT_SSH
to
C:\Windows\SysNative\OpenSSH\ssh.exe
SysNative is a virtual folder, it does not exist on your system physically. But by accessing it, program won't be redirected to SysWOW64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With