It seems git log --follow
always ignore all the merge commits even though the merge commit include some content change different from its parents.
I just use two different branches from master to change the same file and merge them back with --no-ff
. Since two branch change the same file, the later merge conflict. And I just combine the change from the two branch. However, when I try to inspect the change history. I find that "git log" list the latter merge commit as expected. However, "git log --follow" just ignore all merge commit even latter merge actually change some content.
My git version is 2.19.1.windows.1.
My Operating System is windows 10.
My problem could be reproduce with following commands:
# init git repository
git init .
# create a.txt
echo Hello > a.txt
git add a.txt
git commit -m "First commit"
# change a.txt in branch ch1
git checkout -b ch1
echo World >> a.txt
git commit -am "first change"
# change a.txt in branch ch2
git checkout master
git checkout -b ch2
echo Git >> a.txt
git commit -am "second change"
# merge ch1 back into master with no-ff
git checkout master
git merge --no-ff ch1
# merge master into ch2 and resolve conflict
git checkout ch2
git merge master
echo "Hello
World
Git" > a.txt
git commit -a
# merge ch2 back into master with no-ff
git checkout master
git merge --no-ff ch2
Then, in master branch when I run git log --oneline --graph -- a.txt
, I just get:
* 4506bb4 (ch2) Merge branch 'master' into ch2
|\
| * 09c2898 (ch1) first change
* | 0c7e2e6 second change
|/
* 0363441 First commit
When I run git log --oneline --graph --follow -- a.txt
, I just get:
...
| * | 09c2898 (ch1) first change
|/ /
| * 0c7e2e6 second change
|/
* 0363441 First commit
I just expect the same log history with or without --follow
option in this simple scenario. Why git log --follow
seems always ignore the merge commits even though the merge commit actually include some change different from its parent?