'X' does not appear to be a git repository (I'm sure the path is correct)

China☆狼群 提交于 2019-12-19 21:55:56

问题


I want to be able to work from home by cloning of the git repository that exists on my work desktop to my laptop. Both systems are running msysgit within a cygwin shell. Both systems are using cygwin's ssh.

If I ssh to that server, I can see the repository at the path /cygdrive/d/Projects/TheProject

$ ssh TheDesktop
MyUser@TheDesktop's password: ...I enter the password, see the MOTD, and I'm in...
$ cd /cygdrive/d/Projects/TheProject
...See the git repository here.  Even see the current branch in the prompt...

But I try to clone and it fails:

$ git clone ssh://TheDesktop/cygdrive/d/Projects/TheProject
Cloning into TheProject
MyUser@TheDesktop's password: ...I enter the password...
fatal: '/cygdrive/d/Projects/TheProject' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

I've also tried symlinking the repository to my home folder:

$ ssh TheDesktop
MyUser@TheDesktop's password: ...I enter the password...
$ ln -s /cygdrive/d/Projects/TheProject .
$ exit

$ git clone ssh://TheDesktop/~/TheProject
Cloning into TheProject
MyUser@TheDesktop's password: ...I enter the password...
fatal: '/cygdrive/d/Projects/TheProject' does not appear to be a git repository
fatal: The remote end hung up unexpectedly   

I certainly see this error in a lot of questions here, and they almost always relate to a bad path. But I'm really certain my path is correct. I get the feeling it has something to do with the environment being ssh'd into on the desktop, but I really can't figure out what. What other things could cause this error?


回答1:


git clone TheDesktop:cygdrive/d/Projects/TheProject TheProject

should fix it

If the ssh server is not under cygwin, substitute the windows path:

cygpath --mixed /cygdrive/d/Projects/TheProject

It is my experience that cygwin passes the wrong path style to msysgit. Msysgit doesn't understand /cygdrive and therefore messes it up, except with a single argument on the commandline, in which case cygwin bash appears to do the conversion magically.

However, no such thing will be true for gitshell over cygwin sshd. I'm assuming you tried something close to

git clone TheDesktop:D:/Projects/TheProject TheProject

If that didn't work, I'd look at

git daemon # wasn't supported on Windows last time I checked

or

git bundle create repo.bundle --all

# receive it on the remote
scp TheDesktop:repo.bundle
git clone repo.bundle TheProject



回答2:


you need to clone the repository itself, not the associated working tree:

$ git clone ssh://TheDesktop/cygdrive/d/Projects/TheProject/.git TheProject

should work




回答3:


It might have to do with that git wants to find "cygdrive/d/Projects/TheProject" relative to your login folder.

In your first example you login via ssh and then do "cd /cygdrive/...", which is an absolute path, not relative.

Changing your ssh login folder to point to e.g. the Projects-folder might help you out. And also shorten your ssh path :)



来源:https://stackoverflow.com/questions/5731732/x-does-not-appear-to-be-a-git-repository-im-sure-the-path-is-correct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!