【问题标题】:'X' does not appear to be a git repository (I'm sure the path is correct)'X' 似乎不是 git 存储库(我确定路径正确)
【发布时间】:2011-08-09 13:24:01
【问题描述】:

我希望能够通过将工作桌面上存在的 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

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

$ 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 cygwin msysgit openssh


    【解决方案1】:
    git clone TheDesktop:cygdrive/d/Projects/TheProject TheProject
    

    应该修复它

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

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

    根据我的经验,cygwin 将错误的路径样式传递给 msysgit。 Msysgit 不理解 /cygdrive 并因此将其弄乱,except 在命令行上使用单个参数,在这种情况下 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
    

    【讨论】:

    • 更多疑难解答提示
    • 我需要使用 D:/Projects/TheProject 路径而不是 cygwin ssh 路径。非常感谢!
    • 很高兴它有帮助(我很快就能自己使用这些知识了!)
    【解决方案2】:

    您需要克隆存储库本身,而不是关联的工作树:

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

    应该工作

    【讨论】:

      【解决方案3】:

      这可能与 git 想要找到相对于您的登录文件夹的“cygdrive/d/Projects/TheProject”有关。

      在您的第一个示例中,您通过 ssh 登录,然后执行“cd /cygdrive/...”,这是一个绝对路径,而不是相对路径。

      将您的 ssh 登录文件夹更改为指向例如项目文件夹可能会帮助你。并缩短您的 ssh 路径:)

      【讨论】:

      • 好的,所以我 ssh 到桌面和 ln -s /cygdrive/d/Projects/TheProject 到主目录。然后“git clone ssh://TheDesktop/~/TheProject”。我仍然得到同样的错误。我会将其添加到 OP 中。
      猜你喜欢
      • 2022-11-22
      • 1970-01-01
      • 2021-07-28
      • 2017-01-26
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-27
      相关资源
      最近更新 更多