git fetch vs. git fetch origin master have different effects on tracking branch

Viewed 77913

This is mostly of the nature of a curiosity as I'm trying to get familiar with Git. I have looked at the documentation for 'git fetch' but I don't see an obvious explanation for the below. Thanks in advance, and apologies if this is howlingly obvious.

1) From a central repository, say GitHub, I clone a repository named website on each of two machines, HostA and HostB.

2) on HostA, I make a change to a file, say README.txt, and commit it.
At this point on HostA, the commits for branches master and origin/master are, as expected different since I haven't pushed yet

git show master
git show origin/master

report different hashes (since master has the change and origin/master does not)

3) Once I push, they are after that the same.


4) Now, over on HostB, if I do the following:

git fetch
git merge FETCH_HEAD

afterwards, on HostB master and origin/master report the same hash when queried with git show

BUT

if instead I had done, on HostB:

git fetch origin master
git merge FETCH_HEAD

at that point the hashes still differ.

git show origin
git show origin/master

report different hashes

The tracking branch origin/master isn't updated until I do a plain git fetch

Why is this?

3 Answers
Related