为常规合并关闭快进合并,但不为拉动关闭
Turn off fast-forward merging for regular merge, but not for pull
我希望 git 在我使用 git merge
时始终进行合并提交 (--no-ff
),但保留 git pull
的默认行为 (--ff
) ].这可能吗(使用配置)?
可能有用的两个配置是:
merge.ff
(来自 git merge
man page):当设置为 false
时,此变量告诉 Git 在这种情况下创建额外的合并提交(相当于给 --no-ff
命令行中的选项)。
pull.ff
将 pull.ff
设置为 true
将保留默认行为,其中 Git 在合并作为当前提交后代的提交时不会创建额外的合并提交。
待测:pull.ff
是否优先于merge.ff
?
git config pull.ff only
git config merge.ff false
如 Kelvin's and confirmed by git-pull.sh
所述,“only
”是要使用的值,而不是“true
”。
这是我的暂定工作流程(请注意 pull.ff
配置选项仅适用于 git 2.x。
使用此配置:
- 将
merge.ff
设置为 false
。这会将 merge
行为默认为 --no-ff
。
- 将
pull.ff
设置为 only
。这会将 pull
行为默认为 --ff-only
。
这意味着如果您尝试 pull
一个您的本地分支既落后又领先远程的分支,pull
将会失败。在那种情况下,做一个 rebase
这样你就不会再落后了。
注:
我尝试将 pull.ff
设置为 true
,但 git 似乎将其视为该选项完全未设置。请注意,手册页没有提到 true
是公认的值。
我希望 git 在我使用 git merge
时始终进行合并提交 (--no-ff
),但保留 git pull
的默认行为 (--ff
) ].这可能吗(使用配置)?
可能有用的两个配置是:
merge.ff
(来自 git merge
man page):当设置为 false
时,此变量告诉 Git 在这种情况下创建额外的合并提交(相当于给 --no-ff
命令行中的选项)。
pull.ff
将 pull.ff
设置为 true
将保留默认行为,其中 Git 在合并作为当前提交后代的提交时不会创建额外的合并提交。
待测:pull.ff
是否优先于merge.ff
?
git config pull.ff only
git config merge.ff false
如 Kelvin's git-pull.sh
所述,“only
”是要使用的值,而不是“true
”。
这是我的暂定工作流程(请注意 pull.ff
配置选项仅适用于 git 2.x。
使用此配置:
- 将
merge.ff
设置为false
。这会将merge
行为默认为--no-ff
。 - 将
pull.ff
设置为only
。这会将pull
行为默认为--ff-only
。
这意味着如果您尝试 pull
一个您的本地分支既落后又领先远程的分支,pull
将会失败。在那种情况下,做一个 rebase
这样你就不会再落后了。
注:
我尝试将 pull.ff
设置为 true
,但 git 似乎将其视为该选项完全未设置。请注意,手册页没有提到 true
是公认的值。