The command:
git fetch stick master
acts differently in older gits than in the very newest ones.
It tells git to:
- Look up the name
stick
as a remote (which finds the path to the USB stick). - Consult the remote—usually this would be over a network, but in this case, just go look in the other repository—to see what branches it has.
- If the remote has a branch named
master
(which it does), gather up any commits and other objects required. - Finally (this is where the newest gits differ), write those only under the name
FETCH_HEAD
in the local repository; do not update the "remote-branch" information inrefs/remotes/stick/master
.
It's this last step that is causing confusion.
If you run instead:
git fetch stick
this will follow the first two steps, but for steps 3 and 4, it brings over all the branches and does update all the remote-branch information. Then git rev-list stick/master -4
will behave the way you expected it to.
If you upgrade to git 1.8.4 or newer, git fetch
will update the remote-branch information in step 4 even with the two-argument git fetch
form, and again it will behave the way you expected.
Here's what the release notes for 1.8.4 have to say about this:
- "git fetch origin master" unlike "git fetch origin" or "git fetch" did not update "refs/remotes/origin/master"; this was an early design decision to keep the update of remote tracking branches predictable, but in practice it turns out that people find it more convenient to opportunistically update them whenever we have a chance, and we have been updating them when we run "git push" which already breaks the original "predictability" anyway.