I wanted to check commits to a branch, and I saw that there were commits that appear in 2 branches.

Why? What does it mean?

enter image description here


@matisa consider git as a tree which grows with each new commit and branch. Each branch can itself have many commits and child branches which means adjacents branches will always share a common ancestry.

Now git can merge any child branch in any of its ancestors, this does not mean you will lose those intermediate commits since every commit is logged which means we always have a list of all the previous commits and when we can merge any head (child branch) to say in its grandparent.

A -> A|B -> AB|C  (merging C in A)
ABC -> A|B ( merged C in A)

git takes all of those commits which were not present in its grandparent branch which are the commits of child + commits of the parent.

Which leads to the same commit history amongst two branches. So, it is pretty common for branches to have the same commit in their history

I strongly recommend you to read about git here

| improve this answer | |
  • So, basically it is a result of a merge? – matisa Oct 16 '18 at 8:26
  • @matisa merge could be one of the reason, most likely it branches sharing same commit history due to merge – Lalit Yadav Oct 16 '18 at 9:22

I think you might have deleted the non-QA branch in the end after merging and that is why it shows that there is only one existing branch (QA) in the end. You, or someone else, might also deleted their non-QA branch in the third to last commit after merging with QA.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.