git - 'X' 似乎不是 git 存储库(我确定路径是正确的)

标签 git cygwin msysgit openssh

我希望能够通过将工作桌面上存在的 git 存储库克隆到我的笔记本电脑来在家工作。两个系统都在 cygwin shell 中运行 msysgit。两个系统都使用 cygwin 的 ssh。

如果我 ssh 到那个服务器,我可以在路径/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...

但我尝试克隆但失败了:

$ 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

我还尝试将存储库符号链接(symbolic link)到我的主文件夹:

$ 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   

我肯定会在这里的很多问题中看到这个错误,它们几乎总是与错误的路径有关。但我真的很确定我的道路是正确的。我觉得它与在桌面上通过 ssh 进入的环境有关,但我真的无法弄清楚是什么。还有什么其他事情可能导致此错误?

最佳答案

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

应该修复它

如果ssh服务器不在cygwin下,替换windows路径:

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

根据我的经验,cygwin 将错误的路径样式传递给了 msysgit。 Msysgit 不理解/cygdrive,因此把它搞砸了,除了在命令行上有一个参数,在这种情况下,cygwin bash 似乎神奇地进行了转换。

但是,对于 gitshell 而不是 cygwin sshd,这样的事情是不成立的。我假设你尝试了接近

的东西
git clone TheDesktop:D:/Projects/TheProject TheProject

如果不行,我会看看

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

git bundle create repo.bundle --all

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

关于git - 'X' 似乎不是 git 存储库(我确定路径是正确的),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5731732/

相关文章:

git - 如何在 Cygwin 终端中指定 git 路径?

windows - 奇怪的 git 错误

git - msysgit git-am 无法应用它自己的 git 格式补丁序列

git - 在 Git 中,有没有办法自动将 merge 冲突中所有较新版本的文件标记为正确?

git - 什么是 git 的瘦包?

git - 使用 Git 保持 Drupal 更新

c - C 中文件存在的问题

c - 与 write() 函数相关的意外行为

git - 当我得到 "TortoiseMerge cannot be used without a base"时我该怎么办?

git - 如何从两周前或从特定日期开始 git checkout -b ?