如何使 git merge 的默认设置为 --no-ff --no-commit?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5519007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make git merge's default be --no-ff --no-commit?
提问by Stripes
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.
公司政策是--no-ff
用于合并提交。我个人喜欢调整合并日志消息,所以我使用--no-commit
. 另外,我喜欢在提交之前实际编译和测试。
How do I make --no-ff
and --no-commit
the default for me for all branches?
如何让我--no-ff
和--no-commit
我的默认为所有分支机构?
(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...)
(自从问这个问题以来,我在这些年里学到了,我几乎总是对提交感到满意,所以默认情况下允许它提交更简单,只要我在做推送之前修改或以其他方式修复问题是都好...)
回答by William Pursell
Put this in $HOME/.gitconfig:
把它放在 $HOME/.gitconfig 中:
[merge]
ff = no
commit = no
You can use git-config to do this:
你可以使用 git-config 来做到这一点:
git config --global merge.commit no
git config --global merge.ff no
回答by Jian
To make --no-ff --no-commit
the default merge behavior, set the options to no
using:
要进行--no-ff --no-commit
默认合并行为,请将选项设置为no
使用:
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 pull
= git fetch
+ git merge
。因此,无论何时您从远程服务器拉取数据,您都会在需要进行简单快进时创建一个丑陋的合并提交。要解决此问题,请设置pull.ff
为yes
:
git config --global pull.ff yes
回答by gaizka
As of version 1.7.6 of git, you should use
从 git 1.7.6 版本开始,您应该使用
git config [--global] merge.ff no
to "force" using --no-ff
in every merge.
--no-ff
在每次合并中“强制”使用。
Default behaviour is
默认行为是
git config [--global] merge.ff yes
And with
与
git config [--global] merge.ff only
it will refuse non-fast-forward merges
它将拒绝非快进合并