git 如何检查两个分支的冲突,但不需要合并它们?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10879331/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:00:21  来源:igfitidea点击:

How to check the conflict of two branch, but not need to merge them?

git

提问by Jair

I can't merge two branch because of release step of our project, but I want to know whether there are conflict of two branch. How can I do this?

由于我们项目的发布步骤,我无法合并两个分支,但我想知道两个分支是否存在冲突。我怎样才能做到这一点?

回答by Sandro Munda

Suppose you are on the masterbranch and you would like to test if the devbranch can be merged without conflict into the master.

假设您在master分支上并且您想测试该dev分支是否可以无冲突地合并到master.

# In the master branch
git merge dev --no-ff --no-commit

After that, you will be able to know if there's a conflict or not.

之后,您将能够知道是否存在冲突。

To return in a normal situation, just abort the merge:

要在正常情况下返回,只需中止合并:

git merge --abort

git merge --abort

According to the git documentation:

根据 git 文档:

--ff
Do not generate a merge commit if the merge resolved as a fast-forward, only update the branch pointer. This is the default behavior.

-no-ff
Generate a merge commit even if the merge resolved as a fast-forward.

--commit
Perform the merge and commit the result. This option can be used to override --no-commit.

--no-commit
With --no-commit perform the merge but pretend the merge failed and do not autocommit, to give the user a chance to inspect and further tweak the merge result before committing.

--ff
如果合并解析为快进,则不生成合并提交,仅更新分支指针。这是默认行为。

-no-ff
即使合并解析为快进,也生成合并提交。

--commit
执行合并并提交结果。此选项可用于覆盖 --no-commit。

--no-commit
使用 --no-commit 执行合并但假装合并失败并且不自动提交,让用户有机会在提交之前检查并进一步调整合并结果。