Home > Blockchain >  git - ''path'' does not appear to be a git repository
git - ''path'' does not appear to be a git repository

Time:04-13

I'm trying to clone a git repository from my desktop to my laptop.
The desktop is set up as ssh server and accessible from the laptop.

I tried several commands with different url formats,

git clone desktop:workspace/project
git clone desktop:/C:/Users/nkgcp/workspace/project
git clone desktop:~workspace/project
git clone ssh://desktop/workspace/project
git clone ssh://desktop/C:/Users/nkgcp/workspace/project
git clone ssh://desktop/c/Users/nkgcp/workspace/project

but these all returned the same error.

Cloning into 'project'...
fatal: ''workspace/project'' 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.

Note that path on the second line is surrounded with two single quotes.

project exists inside workspace folder and it is definately initialized with git.
workspace folder is inside home directory of my desktop.

The desktop and the laptop is both Windows 10, and desktop uses built-in OpenSSH Server.
This is sshd_config of my desktop,

PubkeyAuthentication yes
PasswordAuthentication no

AllowAgentForwarding no
AllowTcpForwarding no
ChrootDirectory c:/Users/nkgcp

Subsystem   sftp    sftp-server.exe

and this is .ssh/config of my laptop.

Host desktop
    HostName [desktop ip]
    User nkgcp
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_ed25519

How can I solve this?

Thanks in advance.

Edit

I checked debug logs of git ssh.

Cloning into 'project'...
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\nkgcp/.ssh/config
debug1: Connecting to desktop [192.168.25.2] port 22.
debug1: Connection established.
...
debug1: Authentication succeeded (publickey).
Authenticated to desktop ([192.168.25.2]:22).
...
debug1: Sending command: git-upload-pack 'workspace/project'
...
debug1: Exit status 128

You can see only git-upload-pack was executed, so the error might come from this.

CodePudding user response:

First, check that ssh desktop works and open an interactive session.

Then, check that ssh desktop ls /c/Users/nkgcp/workspace/project does list the content of your remote repository.

I would also remove, for testing, the ChrootDirectory directive, just to check if it has a limiting side-effect.

Finally, try the clone command with:

git clone ssh://desktop/c/Users/nkgcp/workspace/project

See if you have any GIT_SSH environment variable, and if not, see if setting it to C:\Program Files\Git\usr\bin\ssh.exe or C:\Windows\Sysnative\OpenSSH\ssh.exe makes any difference.

CodePudding user response:

I just found out why.

cmd.exe seem to only accept double quote(") as string literal.
So when executing git-upload-pack.exe 'workspace/project', not workspace/project but 'workspace/project' is passed as an argument, which results in repository not found error.

To avoid this, you can simply change default ssh shell of your server to powershell.
Or you can use git clone host:repository -u 'powershell git-upload-pack.exe' on the client side.

  • Related