Trying to load files from github through a firewal

2020-05-18 17:10发布

问题:

I'm a little hesitant to post this, as I'm not completely sure what I'm doing. Any help would be wonderful.

I'm on a computer with a firewall/filter on it. I can download files without any difficulty. When I try to clone files from Github, though, the computer just hangs. Nothing happens. It creates a git file in the folder, but the key files don't get loaded in. For context, I'm working on a Rails app, trying to load in Restful Authentication.

Have any of you dealt with this? Any suggestions for getting the clone to work? Disabling the firewall might be an option, but if I can do something without going through that process, I'd appreciate it.

回答1:

Github supports cloning using both the git protocol over port 9418 and HTTP over port 80. Using the later is very slow (Reference). You should open port 9418 on your firewall or use HTTP cloning otherwise.



回答2:

Or... just change the "git://" prefix to "http://"



回答3:

If you're firewalled out of existence and want the speed of git [update: HTTP(S) is practically as fast as ssh these days, but this information is still useful if SSH is the only way to access a repo], and have ssh access to a machine that isn't firewalled, then use an ssh tunnel.

To do so, run this in one window, and leave it running:

$ ssh username@some_host_not_firewalled -L9418:github.com:9418

Then wherever you used the former command:

$ git clone git://github.com/jruby/jruby.git

use this instead:

$ git clone git://localhost/jruby/jruby.git

This translation can be done automatically if you modify your (global) git config:

$ git config --global url.git://localhost/.insteadOf git://github.com/


回答4:

The git:// protocol uses port 9418, so you should make sure your firewall allows outbound connections to this port.



回答5:

I'm use git clone git@ssh.github.com:xxx.user/xxx.proj



回答6:

git config --global url."https://".insteadOf git://

Done!