如何验证GIT分支是否可以仅在没有实际合并的情况下快进合并? [英] How to verify if GIT branch can be merged fast-forward only without actual merging?
问题描述
我试图找到与仅快进选项合并并自动创建合并提交的 GIT 命令,但 --ff-only 不创建自动提交.
I tried to find GIT command to merge with fast-forward only option and auto create merged commit but --ff-only not create auto commit.
因为我想确保我只能进行快进并在合并后创建提交.
Due to the fact that I want to make sure that I can do fast forward only and also create the commit after merging.
不幸的是,这些命令无法帮助我克服这个问题.- --ff-only,进行快进合并但不创建提交- --no-ff,创建自动提交但如果不能应用快进则不停止合并.
Unfortunate, these commands cannot help me to overcome this problem. - --ff-only, do fast-forward merge but not create commit - --no-ff, create auto commit but not stop merging if it cannot apply fast-forward.
因此,我试图找到任何可以验证它是否可以合并快进然后与自动提交合并的命令.
Therefore, I tried to find any commands that can verify if it can merge fast-forward and then merge with auto commit.
请给我一些建议.
非常感谢.
推荐答案
如果您只想快进合并,并且 do 想要合并提交,那么以下似乎有效,即使这听起来很矛盾:
If you want to fast-forward merge only, and do want a merge commit, then the following seems to work, even though it sounds ridiculously contradictory:
git merge [branch] --ff-only --no-ff
它起作用的原因是 --no-ff
实际上意味着即使合并解析为快进,也创建合并提交".这并不意味着不执行快进."
The reason it works is that --no-ff
actually means "Create a merge commit even when the merge resolves as a fast-forward." It doesn't mean "do not perform a fast-forward."
这篇关于如何验证GIT分支是否可以仅在没有实际合并的情况下快进合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!