You can prevent Git from committing automatically with the --no-commit
and --no-ff
flags:
git merge master --no-commit --no-ff
If the current branch and master have diverged, then --no-commit
is enough. If master is simply a couple of revisions ahead then Git will automatically fast-forward, and there isn't really a commit in this case. The --no-ff
prevents this automatic fast forward.
If you do this, the changes that result from the merge will be in a pending state, not committed. I do this when doing code-reviews, as it's easy to diffs in this state. If you do this often it's practical to create an alias for it in your ~/.gitconfig
, for example:
rev = merge --no-ff --no-commit
In the end, I reset and let Git do the committing, as it generates a nice commit log as the summary of all commit logs of the merged revisions.