如何使 git 合并的默认值为—— no-ff —— no-commit?

公司的策略是使用 --no-ff进行合并提交。我个人喜欢调整合并日志消息,所以我使用 --no-commit。另外,我喜欢在提交之前进行实际的编译和测试。

如何使 --no-ff--no-commit成为所有分支的默认值?

(自从我问这个问题以来,我已经学会了,我几乎总是对提交感到高兴,所以默认情况下允许它提交更简单,只要我修改或以其他方式修复事情之前,做一个推动事情都是好的...)

32202 次浏览

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

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

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

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.