Problem with git push remote behind proxy

2019-07-06 01:45发布

To set the context, I am trying to use the toto to set up my blog.
I did

$ sudo gem install toto

and the gems were installed properly.

Successfully installed rdiscount-1.6.8
Successfully installed toto-0.4.9
2 gems installed

After that, I tried

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

but I get the following error

Cloning into myblog...
github.com[0: 207.97.227.239]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)

My git http proxy settings are correct

jatin@jatin-ubuntu:~/myblog$ git config --global http.proxy
http://proxy:port

My http_proxy settings are also correct

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

So, I replaced git by http, as

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

and it worked.

Now, when I do the following

$ cd myblog
$ heroku create myblog

it works till here and I get

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

But it fails down here:

$ git push heroku master

and the following error comes up

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

I didn't know what to do, so after Googling a bit I found that you can't push changes to github using http.
On digging in further, I found this link

how-to-use-the-git-protocol-through-a-http-connect-proxy

which says that you can have your firewall administrator configure the proxy to also allow CONNECT for port 9418, which is the port used by git.

Once they have appropriately configured the proxy, you should then be able to use tools like netcat-openbsd or socat to connect through.

My problem is that I am a student and I can't get around this because I can't reach out to the administrator. I don't know what to do, as I am still stuck looking for an answer.

3条回答
贪生不怕死
2楼-- · 2019-07-06 02:20

You can also push to https://cloudhead@github.com/cloudhead/dorothy.git (note the username in the url).

查看更多
该账号已被封号
3楼-- · 2019-07-06 02:36

You added the heroku remote using this URL git@heroku.com:myblog.git. This was probably configured by the heroku create command.

When you push to this remote, it is done via SSH. And this is exactly what the error message indicates: that you (or git) tried to ssh to heroku.com, but couldn't because of your firewall (probably) denied that. With your git push heroku master command, you are not pushing to Github, but to the git repository at Heroku. To push your stuff to Github, you need to git push origin master and use either ssh or http for the transport. The git:// protocol itself does not support pushing changesets but is an unauthenticated re-only protocol.

Currently, Heroku seems to only allow the SSH transport for its git repos and there don't seem to be any direct hooks on Github (see Push from github to heroku without downloading repo). This means to publish your apps on Heroku, you need to be able to push to heroku.com via SSH from your local host.

查看更多
地球回转人心会变
4楼-- · 2019-07-06 02:36

When you push to this remote, it is done via SSH. The error you are getting is because the client could not connect via SSH, most likely because you are behind some type of firewall that is preventing the connection. I used to have this same problem when trying to push to Heroku from work.

My suggestion would be for you to develop locally and then go to some public hotspot to push the changes to Heroku (like a Starbucks).

查看更多
登录 后发表回答