tags:

views:

131

answers:

1

In response to a question about pulling one commit at a time from a git repository, I was recommended to use git remote update instead of git fetch. I have read both man pages but cannot say I understood either in its entirety.

Can anyone explain to me how git fetch origin and get remote update origin behave differently?

+4  A: 

It makes no difference when used like this.

remote update is a very high-level command - it supports grouped remotes (remotes.<group> = <list>), and updating all remotes (except those with remote.<name>.skipDefaultUpdate set), but not any of the more specific options of fetch. Under the hood, though, it does the exact same thing as fetch with the default options.

The answer recommending remote update instead of git fetch was actually recommending it without a remote name, just for the sake of fetching all, not just the one named as an argument. This is equivalent to git fetch --all.

I should add the caveat that fetch and remote update didn't actually use the same codepath until v1.6.6.1 (released December 23 2009). Even before that, though, they did essentially the same thing, just using different code (possibly behaving slightly differently in corner cases, but I can't think of any off the top of my head).

Jefromi
Very interesting. +1. If you look at the Git release notes (that I have compiled here: http://pastebin.com/LNhRhQS3), it seems that only the 1.7.0 (just after 1.6.6.2) allows "`git fetch --all`" to be used in place of "`git remote update`".
VonC
Ah, I didn't actually check when `fetch --all` went in. I do all this just by variations of `git log --grep=...` and `git describe --contains` in my git.git clone.
Jefromi
Hm, well that's weird - commit 9c4a036b is "Teach the --all option to 'git fetch'", and git describe --contains gives `v1.6.6.1~1^2~9`. (Same release as the remote update change I mentioned in my answer, updated to add the minor release version there). Maybe it was just late getting into the release notes?
Jefromi
@Jefromi: nice way to dig that information out, but I prefer to look first at the release notes and was frustrated by the lack of *one* page for all release notes, hence my little copy-paste in pastebin.
VonC
@Jefromi: right... now I have to find a way to aggregate all the "what's cooking in Git" in order to see why commit 9c4a036b didn't make it in the official release before 1.7 ;)
VonC
@VonC: Yeah, your approach is a lot more user-friendly. I'm just one of those people who has nothing better to do than skim the commit logs every time I pull, looking for exciting new features, so I usually have a pretty good idea what to look for. Best of luck to you digging around in the "what's cooking"!
Jefromi
VonC