【问题标题】:Unable to push to remote repository in Git无法在 Git 中推送到远程存储库
【发布时间】:2012-07-23 19:27:29
【问题描述】:

我正在尝试实现一个简单的场景,我在一台服务器上有一个 git 存储库,并且我能够将此存储库推送到远程服务器。在解决了许多其他问题后,我陷入了以下阶段:

在 server1 上,我有一个 git repo。现在我按照http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push/ 中列出的步骤进行操作

即 1) ssh 到远程服务器 2)创建目录 3) 裸初始化一个 repo 4)退出并在本地服务器上使用以下语句添加远程

   git remote add api User@example.com:/Myproj.git

5) 推送到远程。 (git push -u api master)

我得到的错误是

git: '/Myproj.git' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

如何解决这个问题?我正在使用 MsysGit 1.7.10,并且两台服务器上的 ssh 服务器都是 Cygwin。

=========================

添加 GIT_TRACE=2 git push -u api master 的输出

$ GIT_TRACE=2 git push -u api master
trace: built-in: git 'push' '-u' 'api' 'master'
trace: run_command: 'ssh' 'Administrator@api.example.com' 'git-receive-pack '\''
/Myproj.git'\'''
git: '/Myproj.git' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

=======================

GIT_TRACE=2 git push -u api master 的输出(在进行全局 git 配置更改后)

$ GIT_TRACE=2 git push -u api master 跟踪:内置:git'push''-u''api''master' 跟踪:run_command:'ssh''Administrator@api.example.com''git 接收包'\'' /MyProj.git'\''' 致命:“/MyProj.git”似乎不是 git 存储库 致命:远端意外挂断

【问题讨论】:

    标签: git push msysgit


    【解决方案1】:

    我认为您只需要删除斜线并运行:

    git remote add api User@example.com:Myproj.git
    

    【讨论】:

    • 我也尝试按照此处stackoverflow.com/questions/11571173/… 的建议给出完整路径,但我得到了同样的错误,只是路径不同。
    • GIT_TRACE=2 git push -u api master 的输出添加到问题中。它将显示更多信息。
    • 您可能需要按照here的建议为本地存储库运行git config --local remote.api.receivepack "git receive-pack"
    • 那么GIT_TRACE=2 ...的输出是怎么变化的?
    • 我从路径中删除了冒号,然后它就起作用了。感谢您还展示了如何调试。今天学习一两件事。
    猜你喜欢
    • 2018-06-24
    • 2010-10-25
    • 2021-06-07
    • 2013-01-27
    • 2018-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多