【问题标题】:git push origin master: 'D:/Projects/TheProject' is not a git commandgit push origin master: 'D:/Projects/TheProject' 不是 git 命令
【发布时间】:2012-05-09 11:51:36
【问题描述】:

我有两台机器运行 cygwin ssh 和 msysgit。如'X' does not appear to be a git repository (I'm sure the path is correct) 中所述,我已将一个 git 存储库从我的桌面克隆到我的笔记本电脑。这给我留下了一个 .git/config 如下:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = GitServer:D:/Projects/TheProject
[branch "master"]
    remote = origin
    merge = refs/heads/master

克隆效果很好。 git pull origin 效果很好。但是,如果我尝试“git push origin master”,我会收到以下错误:

$ git push origin master
MyUser@TheDesktop's password:
git: 'D:/Projects/TheProject' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

关于解决此问题的任何想法?

【问题讨论】:

  • 你为什么使用 Cygwin 的 msysgit? Cygwin 有自己的 git 包,它可以与 Cygwin 路径一起使用。相反,msysgit 在 MSYS 中应该更快乐。
  • 我在 cygwin 的 git-svn 上遇到了很多问题,这是台式机用来从我公司的 svn 服务器获取 repo 的。我在cygwin里面运行msysgit是因为整体环境比较完整。

标签: git cygwin msysgit


【解决方案1】:

http://www.cygwin.com/cygwin-ug-net/using.html#cygdrive 建议不要使用“D:/”语法,而是建议使用“/cygdrive/d/”。

看起来 cygwin 没有 chsh,但您可以在 cygwin.bat 中手动将您的 shell 设置为 git-shell

【讨论】:

  • 我必须这样做才能传递 msysgit 的 arg——它不能识别 cygwin 路径。
  • 但它没有......改变它仍然给我同样的错误 - '/cygdrive/d/Projects/TheProject' 不是 git 命令。
【解决方案2】:

您可以使用 cygwin 网址:使用 /d/Projects/TheProject 而不是 D:/Projects/TheProject

【讨论】:

  • 当我试图克隆 repo 时,这是错误的。更改它仍然给我同样的错误 - '/cygdrive/d/Projects/TheProject' 不是 git 命令。
  • 它可能只是/cyg/d/Projects,尝试先cd到它并检查。
  • 可以是 /cyg/d/ , /cygdrive/d/ 或者直接是 /d/
  • ssh to /cygdrive/d/Projects 工作正常,但 msysgit 无法识别这些路径。请参阅我在此处链接的上一个问题。
【解决方案3】:

this question 接受的答案为我修复了它,特别是:

git config --global remote.origin.receivepack "git receive-pack"

【讨论】:

    【解决方案4】:

    首先在客户端运行: git config --global remote.origin.receivepack "git receive-pack"

    CD 到您的本地存储库: cd mylocalrepo

    假设服务器端路径 == c:\gitpub\myproj.git,然后拉/推到服务器 git fetch user@remoteserver.com:c:/gitpub/myproj.git master git push user@remoteserver.com:c:/gitpub/myproj.git master

    当然你可以添加一个远程快捷方式: git remote add myremote user@remoteserver.com:c:/gitpub/myproj.git

    然后: git fetch myremote master git push myremote master

    有关设置 cygwin/ssh 服务器的更多信息,这是我写的一篇文章,讨论了在 Amazon EC2 云中运行的 Windows Server 实例上设置共享 GIT 存储库:

    http://cacheattack.blogspot.com/2012/05/installing-git-server-on-amazon-ec2.html

    【讨论】:

      【解决方案5】:

      如 ak2 的评论中所述,我已切换到使用 cygwin 的 git 版本。现在一切正常。

      但我确实记得为什么我首先避免使用 cygwin git……在使用 git svn 时经常(一天几次)出错。我最终不得不杀死我所有的 cygwin 进程并运行“ash rebaseall”来修复它,或者重新启动我的机器。这很令人沮丧。

      【讨论】:

        猜你喜欢
        • 2021-07-14
        • 2016-04-08
        • 1970-01-01
        • 2021-04-13
        • 2011-08-07
        • 2015-12-08
        • 2017-09-21
        • 2012-09-09
        • 1970-01-01
        相关资源
        最近更新 更多