Joe Cho
Joe Cho

Reputation: 159

Two Git merges have a same commit hash ID

I have a problem in Git log; it seems that my team lost some changes.

I am questioning if two merge commits can share a same commit Hash ID. For example, a merge commit merges commit A and commit B yesterday. In Git log, another commit merges commit C and commit B today. Can it happen in normal situation?

[Update] The Git log looks like below. I am not sure if it IS SHA-1 collision; my concern is that I can see two merges that have the same ccccccc commit. I hope it have my question clear.

=============================================================
commit yyyyyyy
Merge: aaaaaaa ccccccc
Author: Joe myself
Date:   Today some time

    Merge remote-tracking branch 'origin/a-branch' into feature-branch

commit xxxxxxx
Merge: bbbbbbb ccccccc
Author: Kim
Date:   Two days ago some time

    Merge branch 'develop' of https://..... into her-branch

commit ccccccc
Merge: ddddddd eeeeeee
Author: Joe myself
Date:   Two days ago some time

    Merge remote-tracking branch 'origin/another-branch' into a-branch
=============================================================

Upvotes: 0

Views: 2215

Answers (1)

Matt Clark
Matt Clark

Reputation: 28589

See this post that explains the chances of a collision between two SHA-1 hashes; this situations is very unlikely, however still not entirely impossible.

Most visual git explorers will only show the first 8 digits of the hash, which while still very unlikely, is much more probable then the whole hash collision.

Run git log and examine your commits, my thought is that you may have misread something - I'll give you an award if you actually did get a collision :D

If you want, [edit] your post to add in the contents of the git log where you think you may have an issue for us to better understand your issue.

Cheers.

Upvotes: 2

Related Questions