On running git log
i am seeing strange graph. I will explain it further.
Below is the output for git log with graph.
$ git log --graph --oneline
* df1834d (HEAD -> master, tag: r-0.1, origin/master) Merge branch 'master' of https://github.com/samshers/graphql-hibernate
|\
| * d56a675 fixed country null issue
* | ee9bb70 fixed country null issue
|/
* 2617f2a hibernate cascade error issue. country field in state table set to null
As you an see master has two separate branches in itself. To confirm this further, i ran
$ git branch --contains ee9bb706c8fcc329fac4acf69ad6b684f1069170
joincolumn_issue
ls
mappedBy
* master
And then
$ git branch --contains d56a6751771b1f62d9ceb0bcce9a2391c004ee44
joincolumn_issue
ls
mappedBy
* master
So clearly these two commits are present on master - so then why are there two graphs. How can i know if changes both the commits are present on master. Or if only changes from one of them is actually present on the master, which one of the two?
Edit - following responses from RY and Mark
( if color codes add any further meaning, please hint on that as well.)
So, am further trying to understand why a commit (Y) is not based on previous commit (X) ( if X was committed before Y).
The git log shows that both d56a675
and ee9bb70
where committed at the same time.
commit ee9bb706c8fcc329fac4acf69ad6b684f1069170
Author: itsvamshers <itsvamshers@gmail.com>
Date: Mon Sep 9 17:24:01 2019 +0530
fixed country null issue
commit d56a6751771b1f62d9ceb0bcce9a2391c004ee44
Author: itsvamshers <itsvamshers@gmail.com>
Date: Mon Sep 9 17:24:01 2019 +0530
fixed country null issue
But, on digging further the little difference can be seen..
$ git show -s --format="%ct" d56a6751771b1f62d9ceb0bcce9a2391c004ee44
1568030041
and
$ git show -s --format="%ct" ee9bb706c8fcc329fac4acf69ad6b684f1069170
1568031643
and this info should be enough for git to put the commits in right order. But if it is not, then I guess it is smarter and doing it for reason, just trying to understand the reason and the cause.
d56a675 isn’t present in the history of ee9bb70, and ee9bb70 isn’t present in the history of d56a675. Both are present in the history of master, because they were merged back together in df1834d. All of this is why the graph has a fork in it.
Both of their changes exist in the history of master, but that doesn’t mean the merge commit preserved those changes the way you might want. You have to look at the current state and compare.
git show d56a675
git show ee9bb70
git diff 2617f2a..df1834d
Also, if both commits are the same or if one is a newer version of the other (which their summary suggests), merging them is probably a mistake.