如何在没有实际合并的情况下测试合并 [英] How to test a merge without actually merging first
问题描述
有没有什么方法可以模拟两个分支之间的git merge
,当前工作分支和主分支,但不做任何更改?
Is there any way of simulating a git merge
between two branches, the current working branch and the master, but without making any changes?
当我必须进行 git merge
时,我经常会发生冲突.有没有办法先模拟合并?
I often have conflicts when I have to make a git merge
. Is there any way of simulating the merge first?
推荐答案
我认为在您尝试合并之前,没有办法模拟会发生什么.但是,如果您在进行合并之前确保 git status
的输出为空,那么继续尝试是非常安全的.如果遇到冲突,您可以立即恢复到之前的状态:
I don't think there is a way of simulating what will happen until you try the merge. However, if you make sure that the output of git status
is empty before you do the merge, it is quite safe to just go ahead and try it. If you get conflicts, you can immediately get back to the state you were at before with:
git reset --merge
从 git 1.7.4 开始,您还可以通过以下方式中止合并:
Since git 1.7.4, you can also abort the merge by doing:
git merge --abort
(正如 添加该选项的提交消息所解释的,这是为了与 git 保持一致而添加的rebase --abort
等等.)
(As the commit message that added that option explains, this was added for consistency with git rebase --abort
and so on.)
这篇关于如何在没有实际合并的情况下测试合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!