Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

merge

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...)

like image 555
Stripes Avatar asked Apr 01 '11 21:04

Stripes


People also ask

What does -- no FF mean in git?

Using the --no-ff parameter prevents the Git merge command from performing a fast-forward merge when Git detects that the current HEAD is an ancestor of the commit that you're trying to merge.

When should I use git no FF?

The --no-ff flag prevents git merge from executing a "fast-forward" if it detects that your current HEAD is an ancestor of the commit you're trying to merge. A fast-forward is when, instead of constructing a merge commit, git just moves your branch pointer to point at the incoming commit.

Can I merge without commit?

With --no-commit perform the merge and stop just before creating a merge commit, to give the user a chance to inspect and further tweak the merge result before committing. Note that fast-forward updates do not create a merge commit and therefore there is no way to stop those merges with --no-commit.

What is git FF only?

How Git Pull –ff-only Works. Fortunately, Git gives us an option that prevents the accidental creation of new shas in your repository. With git pull --ff-only , Git will update your branch only if it can be “fast-forwarded” without creating new commits.


2 Answers

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 
like image 93
William Pursell Avatar answered Oct 01 '22 07:10

William Pursell


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 
like image 36
Jian Avatar answered Oct 01 '22 06:10

Jian