Live data from Hacker News

Speed Up Git Pull

interrobeng.com

41–50 of 50 posts

Re: Speed Up Git Pull

#41
post #40
post #38

Earlier quoted context omitted.

> Now I also have a cache for when GitHub goes down (all the time.) Isn't the `.git` a cache for when github goes down? Git keeps all of your history inside your repository; you don't need network access to do anything.

Sort of. I've automated synchronizing it with the GitHub repo, so my local repo may be behind the cached repo. I'm also protected if a repository is deleted/moved/DMCAed.

What benefits does this provide that a cron job running `git fetch` doesn't?

Re: Speed Up Git Pull

#42
post #23

Earlier quoted context omitted.

http://xkcd.com/1205/ If you pull 10 times a day (conservative for me) then you’ll save ~5 hours over a year.

But couldn't it very well take more than 5 hours to set this up?

Doesn't matter too much. A short wait can throw you out of focus, and it's the time you spend getting back into focus that's important.

Re: Speed Up Git Pull

#43
post #14

Earlier quoted context omitted.

No. I have this enabled and Github closes my connections after a very short period. I use it primarily for SSHing into my cluster of EC2 instances (which does massively speed things up).

Same here. I do a (ssh -fqN -o "StrictHostKeyChecking no" git@bitbucket.org >&/dev/null &) with bitbucket and github in my zshrc and bitbucket stays open but github is getting closed at some point. It used to stay open however.

They could offer it as a premium feature.

Re: Speed Up Git Pull

#45
post #9

Hrm, so this isn't about making git 50x faster but fast network communication. > Establishing an SSH connection every time you perform a Git operation costs many round-trips I don't really understand why the author is saying this. The whole point of git is to be distributed and not to push/pull at each commit. That being said, he found something that speeds up his workflow tremendously, so congratulations.

Oh, you might still want to share your commits with your coworkers, and for that you need to push and/or pull. (You could do that asynchronously, though.)

Re: Speed Up Git Pull

#46
post #41
post #40

Earlier quoted context omitted.

Sort of. I've automated synchronizing it with the GitHub repo, so my local repo may be behind the cached repo. I'm also protected if a repository is deleted/moved/DMCAed.

What benefits does this provide that a cron job running `git fetch` doesn't?

Redundancy, public access and not having hundreds of unused repositories on my computer. I'm not trying to sell anyone on the idea, it just works for me and I like it so whatever.

Re: Speed Up Git Pull

#47
post #5

A 50x speedup is pretty cool in its own right. Kudos. However, I wonder if this isn't treating a symptom versus a root cause. Is saving that 5s round-trip so common in your workflow that you needed to optimize it, and would it be more productive to refactor the app so you and collaborators are working on different files? Also, this has the entirely valuable guidance that pushing to a local server is much faster than…

How would refactoring help? You still need to fetch before you can push to git.

Re: Speed Up Git Pull

#48
I just tried the first part of this (the ssh multiplexing) and instead of getting faster, 'git fetch' got slower (1.9 to 2.4 seconds). Any ideas why, and how I can debug/improve it?

Re: Speed Up Git Pull

#49
post #9

Hrm, so this isn't about making git 50x faster but fast network communication. > Establishing an SSH connection every time you perform a Git operation costs many round-trips I don't really understand why the author is saying this. The whole point of git is to be distributed and not to push/pull at each commit. That being said, he found something that speeds up his workflow tremendously, so congratulations.

Even with a short timeout (say, 10 seconds), it could be useful for a maintainer who pulls from several other users' GitHub repositories. Instead of establishing a new SSH connection for each remote, a complete "git remote update" of multiple repositories could be done over a single connection.

Re: Speed Up Git Pull

#50
post #37

Earlier quoted context omitted.

One that I frequently run into is that if you use SSH tunneling (like -L), you have to specify it the first time you ssh to that machine (i.e. when the ControlMaster is connected) and can't change it later. Using -L on later ssh's to the same machine silently fail, which can be infuriating if you don't realise it's happening. The best you can do at that point is to kill the ControlMaster ssh (disconnecting you across…

You can skip the master and spawn a fresh connection for your tunnel using `-o ControlPath=none`.

In fact, even better: you can add forwarding to your existing connection. ~C opens a command line, which accepts the following commands:

    ssh> help
    Commands:
      -L[bind_address:]port:host:hostport    Request local forward
      -R[bind_address:]port:host:hostport    Request remote forward
      -D[bind_address:]port                  Request dynamic forward
      -KR[bind_address:]port                 Cancel remote forward
(If you're not familiar with them, some of the other escape sequences are useful too. ~? lists them all.)

[EDIT] Apparently, if you have a recent enough version, you can add a forward to the master with `ssh -O forward ...` [1]

[1] http://serverfault.com/questions/237688/adding-port-forwardi...

Post reply on HN