1

I have a Windows Server that is accessible through SSH, on the server, I went to C:\Users\ftptest and ran git init --bare MyRepo.git

On the client, I'm attempting to clone the new repo with git clone ftptest@my-server:MyRepo.git but I get the error:

fatal: ''MyRepo.git'' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

I'm guessing there's something wrong with my URL and Git is looking for the repo in the wrong directory. What would be the correct command to clone the repo?

FWIW, my server is already accessible through SSH (I'm using OpenSSH), when I issue the git clone it performs authorization and rejects wrong passwords.

0

1 Answer 1

2

Git runs the remote git handler as a shell command (which is really the only way to run things over SSH) and passes it the repository path as a command-line parameter. Without knowing anything about the server, it expects a POSIX-compatible shell (sh/bash/zsh) and uses ' single quotes ' around the path:

  • Client side:

    ssh myserver "git-upload-pack 'MyRepo.git'" 
  • Remote side:

    git-upload-pack 'MyRepo.git' 

("git-upload-pack" is called to handle clone/fetch/pull from the server – it "uploads" packfiles to you – while "git-receive-pack" handles push into the server.)

This is not recognized by Cmd (well, Cmd leaves it to programs themselves to dequote their parameters, so more accurately this is not recognized by Git for Windows), so the remote Git handler assumes the single quotes are part of the path, making the path invalid.

You could either a) make the OpenSSH server run PowerShell instead, which might handle this syntax:

or b) put a git-upload-pack.cmd in one of your %PATH% folders that would handle the command:

@"C:\Program Files\Git\bin\sh" -c "'/c/Program Files/Git/bin/git' upload-pack %*" 

Repeat for git-receive-pack.cmd with the 'receive-pack' command. This really isn't an ideal option, it's just what I used in 2010 with Bitvise sshd.

1
  • Setting the default shell to powershell worked for me, thanks. Commented Jul 15 at 8:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.