【问题标题】:Cannot 'git push' - the remote end hung up unexpectedly无法 'git push' - 远端意外挂断
【发布时间】:2013-01-06 00:44:08
【问题描述】:

我在本地机器上有一个 git 存储库,我将它推送到 github 和一个由 HostGator 托管的登台服务器。我跟着this guide 设置了我的登台服务器以允许我推送到它,这在过去运行良好。

在大约一个月没有推送任何内容后,我现在在尝试推送到临时服务器时看到此错误(其中 [hostname] 被我的 url 替换):

ssh: connect to host [hostname] port 22: Operation timed out
fatal: The remote end hung up unexpectedly

git remote -v 显示:

bright  [user]@[hostname]:[path to repo] (fetch)
bright  [user]@[hostname]:[path to repo] (push)
origin  git@github.com:[reponame.git] (fetch)
origin  git@github.com:[reponame.git] (push)

我的 .git/config 的相关部分如下:

[remote "[remote in question"]
    url = [user]@[hostname]:[path to repo]
    fetch = +refs/heads/*:refs/remotes/[remote]/*

值得注意的是,当我ssh 进入此服务器时,我使用端口 2222,但从错误消息中可以看出,git 正在尝试使用端口 22。我认为情况一直如此,即使它工作正常。

我可以采取哪些步骤来确定git push 在我的登台服务器上超时的原因?

【问题讨论】:

    标签: macos git ssh


    【解决方案1】:

    听起来您可能在本地 ~/.ssh/config 文件中设置了端口 2222。也许该配置已被替换或删除?

    【讨论】:

    • 我的本地 ~/.ssh/config 指定端口 2222。我正在使用 Mac 并通过命令行执行所有操作。看来我需要弄清楚 git 如何决定使用什么 ssh 设置。
    【解决方案2】:

    需要在远程定义中指定端口使用:

    url = git://[user]@[host]:2222/[path_to_repo]
    

    这只能使用上述以 git:// 开头的样式 url。

    【讨论】:

      猜你喜欢
      • 2012-08-19
      • 1970-01-01
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 2016-04-23
      相关资源
      最近更新 更多