Merge fast-fowards to another branch and no commit record is created
I have a master branch and debug branch. They are one commit apart. debug branch is branched from master and has one commit. When I merge them, git fast-fowards master branch to debug branch, not creating another commit as I am familiar. It is missing some information, namely comments, from the master branch (which becomes HEAD^ after the merge). I have several questions:
How come it does not create another commit with the comment that denotes branches have been merged?
What is the criteria for fast forward?
Should I be paranoid about the fast-foward merge and check it every time?
I do not think I have anything in
.gitconfig file that may affect the behavior:
[merge] tool = fugitive [push] default = upstream [diff] tool = vimdiff [mergetool "fugitive"] cmd = vim -f -c \"Gdiff\" \"$MERGED\" [difftool] prompt = false
One Solution collect form web for “Merge fast-fowards to another branch and no commit record is created”
Git will by default do a fast forward merge when the commit you are merging in points to the current commit as a parent (a Git commit (almost) always contain a pointer to it’s parent(s), i.e. predecessor(s)).
Here, commit A is on develop and B is on master
C <--- B <--- A older stuff master develop
After a fast forward merge (
git checkout master; git merge develop):
C <--- B <--- A older stuff develop master
In this scenario there can be no conflicts.
Compare this to a more complex merge
C - B' \ A'
Here B’ and A’ can have introduced changes in the same places, so conflicts can occur hand have to be able to be resolved in a merge commit M
C - B'-M \ / A'
If you do not want the default fast forward merge behavior you can use the –no-ff switch.
git merge --no-ff develop on the first example above would produce.
C - B - M (master) \ / A develop
M is the merge commit that was forced. Master is at M and develop is at B.
People actually tend to be more paranoid about merges that are not fast forward, since they have the potential of creating buggy conflicts. If you wish to make sure that the merge only goes ahead if it will be a fast forward you can do
git merge --ff-only develop
So, the Git behavior you are seeing is standard and there is nothing wrong with your
This answer has more details.