Usually when two branches coincide on the same source code state, they will hash the same and appear collapsed together. But I have found myself in an interesting state (described in the title).
Here is how I got there. I had an old branch from last week, and I merged many changes from master into it. At this point it was a fast-forward and furthermore there was no difference from master.
But when I merged a feature branch into this branch (which is pretty much had the same state as master) it ended up like this:
* b0dc045 - (new-branch) refactored it. seems to work fine
| * 4b89219 - (HEAD -> feature, origin/feature) refactored it. seems to work fine
|/
* Merge branch 'master' into 'feature'
|\
...
'master' is way down below somewhere...
So anyways, git diff new-branch feature
shows no diff... but they got different hashes.....
What are some things I can check to really see where they really differ?
Update:
I guess aspects of the history of a branch is included in the set of data that generates the hash. This would explain the disparity.
So I did a quick and dirty trick
$ diff <(git log new-branch) <(git log feature)
1c1
< commit b0dc045b82cfc2f7060ccd3b28dd1b1ca1cf2a59
---
> commit 4b8921960cc8f1d42e3e4d1b505228a2dc0c0638
It shows that the hash is different on the first line. This is the part that is puzzling. It also shows that the rest of the 24 thousand line git log is identical.
That is because the commit message, time, author, and parent commit IDs are a part of the hash. This ensures that noone can change these fields after a commit has been published and further development has been done on top of it.
But, of course, it also allows you to recommit the same state with as many different authors, commit times, messages, and histories as you please. Each time, you will get a different hash, and thus another commit that has no content differences.
credit goes to @larsks for the commands
$ git cat-file -p new-branch; git cat-file -p feature;
tree 26e6e56076b5578100857218df0cbed7fcab10a3
parent 72f868f7fd45ecabef78cab23f120d48a04bf38d
author Steven Lu (PuTTY Win7 on Centos 7 VM Feb26[tmux]) <[email protected]> 1439228778 -0400
committer Steven Lu (Centos 7 VM Feb26) <[email protected]> 1439230770 -0400
refactored it. seems to work fine
tree 26e6e56076b5578100857218df0cbed7fcab10a3
parent 72f868f7fd45ecabef78cab23f120d48a04bf38d
author Steven Lu (PuTTY Win7 on Centos 7 VM Feb26[tmux]) <[email protected]> 1439228778 -0400
committer Steven Lu (Centos 7 VM Feb26) <[email protected]> 1439228778 -0400
refactored it. seems to work fine
The delta is in the committer time of new-branch
.
That's craaaaazy maaaaan.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With