How do I make git merge's default be --no-ff --no-commit?

GitMerge

Git Problem Overview


Company policy is to use --no-ff for merge commits. I personally like to adjust merge log messages so I use --no-commit. Plus I like to actually compile and test before I let the commit go.

How do I make --no-ff and --no-commit the default for me for all branches?

(and I've learned in the years since asking this, I almost always am happy with the commit, so it is simpler to allow it to commit by default and so long as I amend or otherwise fix things up before doing a push things are all good...)

Git Solutions


Solution 1 - Git

Put this in $HOME/.gitconfig:

[merge]
    ff = no
    commit = no

You can use git-config to do this:

  git config --global merge.commit no
  git config --global merge.ff no

Solution 2 - Git

To make --no-ff --no-commit the default merge behavior, set the options to no using:

git config --global merge.ff no
git config --global merge.commit no

However, the problem with this is that git pull = git fetch + git merge. So whenever you pull from the remote server, you'd be creating an ugly merge commit when a simple fast-forward would be warranted. To solve this, set pull.ff to yes:

git config --global pull.ff yes

Solution 3 - Git

As of version 1.7.6 of git, you should use

git config [--global] merge.ff no

to "force" using --no-ff in every merge.

Default behaviour is

git config [--global] merge.ff yes

And with

git config [--global] merge.ff only

it will refuse non-fast-forward merges

Solution 4 - Git

According to manual, you should use

$ git config [--global] merge.ff false

to set no-fast-forward option by default for all branches with git-config utility.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStripesView Question on Stackoverflow
Solution 1 - GitWilliam PursellView Answer on Stackoverflow
Solution 2 - GitJianView Answer on Stackoverflow
Solution 3 - GitgaizkaView Answer on Stackoverflow
Solution 4 - GitalexglueView Answer on Stackoverflow