how to set up git merge branch commit?
Answered
Hi,
I am searching for a possibility to create automatically an "merge branch" commit on / at branch merge time, like we have in git flow and SourceTree.
In SourceTree it's a checkbox. But I couldn't find the simliar option in PHPStorm. So, does anyone know how to do this? Or where to set it up?
If I merge now, I just got all the commits on the other branch. But there is no indicator in git log, that there was a merge.
Best Regards,
Thomas
Please sign in to leave a comment.
Please clarify, what exact option do you mean in Sourcetree?
Merge commits are created bu the IDE:
I mean that your marked commit is missing every time for me. So, I don't have commits like "Merge branch 'master' into Compare".
This is not configurable and should be always created.
Are you sure you merge, not rebase?
Yes, I am sure. I usually switch in the branch and then I merge the other branch using the context menu at the bottom right screen corner (as you can see in my screenshot). My repo is pretty straight forward. Rebasing or stuff like that was not needed until now:
This is sementical the same as the following git commands:
git checkout master
git merge mybranch
Thanks for the screenshot.
You do not get merge commits. because actually there is nothing to merge. Looking at the graph, branches do not diverge, so the merge just moves the branch reference to corresponding commits.
You should get the same when merging from the command line, because --fast-forward is the default merge behavior unless it is changed in config.
But why do you need the merge commits in such straight history?
Well, simply because I would like to have it every time when I merge, to get a nice history. Sorry, I didn't know that is git default behaviour. I knew, there are a few merge strategies, but I think there is no merge strategy that I would like to have, isn't there?
I believe in your case, forcing merge commits will make the history cluttered. Instead of a straight graph, you will get something like this.
Personally, I see no reason for this, cause in the case of several branches graph could become cluttered.
You could do this, however, using --no-ff flag for merge.
From the IDE, you will need to use VCS - Git - Merge changes, and enable the No fast forward option.