git:// through proxy

I’m behind a firewall that is blocking port 9418 (git) and am trying to install some tools that are explicitly doing a checkout of git://github.com/..., so I can’t switch to https for the checkout.

So I’m wondering if it’s possible to redirect all traffic to port 9418 through a proxy and if so how 🙂

  • Configure git to allow cli push/pull without password prompt - netrc ignored?
  • How to interpret this Emacs magit help screen?
  • How to get git parent branch name of current branch?
  • How To Automagically Remove Commits That Cancel Themselves Out In Git
  • gitignore: Ignoring a folder (anywhere) except for a subfolder (anywhere)
  • dcommit to SVN in 1 commit after cherry-picking in git
  • Deploy from bitbucket to live server
  • Remove repository from GitKraken overview
  • In git, how can I remove Windows line endings from changed lines only?
  • How to get ONLY filename with path using git log?
  • .gitignore for directories at a specific depth?
  • Git: How to find all commits in branch A that originated in derived branch B merged back into A?
  • 4 Solutions collect form web for “git:// through proxy”

    Have a look at core.gitproxy setting in Git config.

    Quick googling revealed this script that may be useful (or may not — I did not try it): https://gist.github.com/49288

    If you are talking about git submodules, try this:

    git config --global url.https://github.com/.insteadOf git://github.com/
    

    …taken from here.

    This way, you don’t need to set any proxy, nor run any script.

    Have you tried an ssh-based TCP tunnel? If you have an ssh server that (a) is outside your firewall and (b) allows IP forwarding, you can do:

    ssh -L localhost:9418:<remote>:9418 me@remote-ssh-server
    

    or, if you have to run sshd on port 443 to get around your firewall,

    ssh -P 443 -L localhost:9418:<remote-host>:9418 me@remote-ssh-server
    

    Then, locally:

    git checkout git://localhost/...
    

    Obviously this isn’t transparent, and it’s a little convoluted – there are no doubt tools out there that are more specifically targetted at the problem. However, I typically use this method because it uses tools I have to hand (ssh and a cheapo virtual server I rent).

    (I’ve actually never tried this with a git connection, but I see no reason why it wouldn’t work. I’ve used it with many other single-TCP-port protocols without problem.)

    You need to make core.gitProxy point to a proxy command that will connect git to the remote server through your SOCKS proxy. You can create a script with the following content to serve as a proxy command:

    nc -x <your_proxy_host>:<your_proxy_port> $1 $2
    

    The two parameters, representing the remote host and port, will be passed to the proxy command by git. If you name this script git-proxy and make it accessible from your $PATH, you can call git config to set it:

    git config --global --add core.gitProxy git-proxy
    
    Git Baby is a git and github fan, let's start git clone.