Albert Callarisa Roca

Tech blog

Speed up Github connection

13 Sep 2013

I live in Singapore. This is the standard time a git pull takes:


$ time git pull
Already up-to-date.

real  0m5.272s
user  0m0.045s
sys 0m0.037s
  

It's a bit annoying to wait so much every single time git needs to access the github remote. To solve that, it's possible to keep a ssh connection open with github and use it instead of opening a new one every time.

To do so, add the following lines to your ~/.ssh/config file:


Host github.com
  TCPKeepAlive yes
  ServerAliveInterval 60
  ControlMaster auto
  ControlPath ~/.ssh/connection-%r@%h:%p
  

After that, to keep a connection open with github run the following command and send it to the background:


ssh -fN [email protected]
  

When this is running, this is the new time for a git pull:


$ time git pull
Already up-to-date.

real  0m1.593s
user  0m0.032s
sys 0m0.033s