0

I have Windows 10. Able to work with git/stash repos using SourceTree. ssh keys are configured. But not able to work with git using GitBash or Visual Studio Code terminal. The error screenshots are below. Tried creating another key pair and added to stash, but still no luck. Any pointers on this would be highly helpful.

Note: Regular git commands like git status, git etc works. issue is only when I try to do something over remote git like git pull, push etc. I am able to do all these from source tree without an issue. Issue is only on GitBash

    $ git clone ssh://git@stash.xyz.com/repo/project.git
Cloning into 'project'...
/usr/bin/sh: git@stash.xyz.com: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

GIT TRACE results:

$ GIT_TRACE=1 git status
09:56:49.057073 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
09:56:49.062073 git.c:444               trace: built-in: git status
On branch dev
Your branch is behind 'origin/dev' by 2 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

nothing to commit, working tree clean



user@123456 MINGW64 ~/dev/project (dev)
$ GIT_TRACE=1 git pull
09:57:02.104645 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/bin
09:57:02.109645 git.c:444               trace: built-in: git pull
09:57:02.112645 run-command.c:664       trace: run_command: git fetch --update-head-ok
09:57:02.352647 exec-cmd.c:237          trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core
09:57:02.356646 git.c:444               trace: built-in: git fetch --update-head-ok
09:57:02.361646 run-command.c:664       trace: run_command: GIT_PROTOCOL=version=2 'C:\Program Files\Git\usr\bin\sh.exe' -G -o SendEnv=GIT_PROTOCOL git@stash.xyz.com
09:57:02.598649 run-command.c:664       trace: run_command: unset GIT_PREFIX; 'C:\Program Files\Git\usr\bin\sh.exe' git@stash.xyz.com 'git-upload-pack '\''/abcd/project.git'\'''
/usr/bin/sh: git@stash.xyz.com: No such file or directory
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
suj
  • 507
  • 1
  • 8
  • 22
  • Hi! Do you have more than one ssh key? You can export the SSH key during the command execution, for example: https://stackoverflow.com/a/4565746/5220215 – Vivi Ch May 26 '22 at 05:12
  • 1
    Your `/usr/bin/sh` is, for some reason, attempting to run `git@stash.xyz.com` as a *command* rather than reaching out *to* `git@stash.xyz.com` to run a command there. Figure out why (try tracing system calls through `strace -i` or whatever your OS uses). Use `GIT_TRACE` to see what you're having Git itself run (did you set `core.sshCommand` to something odd?). – torek May 26 '22 at 07:37
  • @torek nothing wrong seems with key. authentication is successful. Can you see the trace report below. git status works but not commands like git pull and clone.. do you see any clues? updated the trace in original questions as I couldn't not add as comment,. – suj May 27 '22 at 00:57
  • 1
    (Updating the question like this is the right thing to do.) So, it looks like the ssh command for Git is no command at all, which explains the behavior. Why it's no command at all is now the next question. Is `GIT_SSH` or `GIT_SSH_COMMAND` set? Is `core.sshCommand` set? If so, to what? Setting `GIT_SSH_COMMAND` to `ssh` may work around the problem. – torek May 27 '22 at 05:03
  • @torek awesome, setting the var `export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa"` seems to have solved the problem – suj May 27 '22 at 05:39

0 Answers0