代理后git push远程出现问题

3
为了解释这个问题,我正在尝试使用 toto 来建立我的博客。
我运行了以下命令:

$ sudo gem install toto

gems 已经成功安装。
Successfully installed rdiscount-1.6.8
Successfully installed toto-0.4.9
2 gems installed

之后,我尝试了

$ git clone git://github.com/cloudhead/dorothy.git myblog

但是我遇到了以下错误。
Cloning into myblog...
github.com[0: 207.97.227.239]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)

我的git http代理设置是正确的。
jatin@jatin-ubuntu:~/myblog$ git config --global http.proxy
http://proxy:port

我的http_proxy设置也是正确的。


jatin@jatin-ubuntu:~$ echo $http_proxy
http://proxy:port/

所以,我用http代替了git,因为
$ git clone http://github.com/cloudhead/dorothy.git myblog

并且它有效了。 现在,当我执行以下操作:
$ cd myblog
$ heroku create myblog

到这里它是工作正常的,我得到了

Creating myblog...... done
Created http://myblog.heroku.com/ | git@heroku.com:myblog.git
Git remote heroku added

但是它在这里失败了:
$ git push heroku master

然后出现了以下错误

ssh: connect to host heroku.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly

我不知道该怎么办,所以在谷歌搜索一番后,发现无法使用http推送更改到Github。
进一步查找后,我找到了这个链接:如何通过HTTP连接代理使用git协议,其中说明您可以让防火墙管理员配置代理,以允许端口9418上的CONNECT,这是git使用的端口。
一旦他们适当地配置了代理,您应该能够使用netcat-openbsd或socat等工具进行连接。
我的问题是我是一名学生,因为我无法联系管理员而束手无策。我不知道该怎么做,我还在寻找答案。
3个回答

6
您使用以下URL git@heroku.com:myblog.git 添加了heroku远程。这可能是通过heroku create命令配置的。
当您推送到此远程时,它是通过SSH完成的。而这正是错误消息所指示的:您(或git)尝试ssh到heroku.com,但由于您的防火墙(可能)拒绝了该操作,因此无法连接。使用git push heroku master命令,您并没有将其推送到Github,而是将其推送到Heroku上的git存储库。要将您的内容推送到Github,您需要使用ssh或http进行传输,并使用git push origin master命令。 git://协议本身不支持推送变更集,而是一个未经身份验证的只读协议。
目前,Heroku似乎仅允许其git存储库使用SSH传输,而在Github上似乎没有直接的钩子(请参见Push from github to heroku without downloading repo)。这意味着要在Heroku上发布您的应用程序,您需要能够从本地主机通过SSH推送到heroku.com。

2

我尝试使用git push https://github_username@github.com/app_name.git进行推送,但是它返回了一个错误:error: The requested URL returned error: 500 while accessing https://github_username@github.com/app_name.git/info/refs - Jatin Ganhotra
@Jatin:你好像忘记在仓库路径中加入仓库所有者。你需要在 @(作为用户名)和 github.com 后面(作为仓库所有者)加上 cloudhead。 - Holger Just

1

当您推送到此远程时,它是通过SSH完成的。您收到的错误是因为客户端无法通过SSH连接,很可能是因为您在某种类型的防火墙后面,该防火墙正在阻止连接。我曾经在尝试从工作地点推送到Heroku时遇到过同样的问题。

我的建议是您在本地开发,然后去一些公共热点推送更改到Heroku(比如星巴克)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接