Can't get VS2019 to fetch/push to the remote (happens to be on GitLab). What is the correct configuration?
I'm using the built-in Windows 10 OpenSSH (C:\Windows\System32\OpenSSH
)
I've set env var GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe
Private key loaded into running ssh-agent
service via ssh-add
.
From a normal command window (i.e., not a WSL bash shell) I can push/fetch to my heart's delight.
From VS2019, with the repo open (Git>Local Repositories>myrepo
), when I try either Git>Fetch
or Git>Push
I get the following in the output window:
Commit eebc0b4a created locally in repository r:\bbits\edu-bitcoin-staging
Opening repositories:
r:\bbits\edu-bitcoin-staging
Pushing master
Pushing to gitlab.com:bakins-bits/edu-bitcoin-staging.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.
Git failed with a fatal error.
unable to fork
Failed to push to the remote repository. See the Output window for more details.
Note the C:\Windows\System32\OpenSSH\ssh.exe: No such file or directory
- and yet, that's the correct path:
C:\>dir C:\Windows\System32\OpenSSH\ssh.exe
Volume in drive C is P70-MSVC
Volume Serial Number is 8240-9525
Directory of C:\Windows\System32\OpenSSH
10/15/2019 06:50 AM 882,688 ssh.exe
1 File(s) 882,688 bytes
0 Dir(s) 333,358,600,192 bytes free
I think I've managed to resolve the issue here. 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
Use this to escape space in "Program Files"
git config --global core.sshCommand 'C:\\PROGRA~1\\\\Git\\usr\\bin\\ssh.exe'
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