可以告诉我合并是否会发生冲突而不实际合并? [英] Can git tell me if a merge will conflict without actually merging?

查看:119
本文介绍了可以告诉我合并是否会发生冲突而不实际合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能知道合并是否会发生冲突,而不触摸工作树?我不想触摸工作树,因为我不想让它检出。这需要很长时间,如果我想看到这个信息的几个分支。

Is it possible to know if a merge will conflict or not, without touching the working tree? I don't want to touch the working tree because I don't want to have it checked-out. That would take a long time if I want to see this information for several branches.

推荐答案

我假设你只是想在实际尝试合并之前发现自己陷入了多少麻烦......并且在合并失败后重置为最后一次提交相对容易,所以如果这是预期方法,我不会感到惊讶。

I'm assuming you just want to find out how much trouble you're getting yourself into prior to actually attempting the merge...and resetting to the last commit after a failed merge is relatively easy so I wouldn't be surprised if that is the intended approach.

也就是说,如果你真的不想触摸工作树中的现有文件 - 你可以创建一个补丁并针对目标分支进行测试。这还具有显示对哪些文件进行了哪些更改的好处 - 只需在文本编辑器中打开补丁文件即可。

That said, if you really don't want to touch your existing files in the working tree - you could create a patch and test it against the target branch. This also has the benefit of showing exactly what changes were made to which files - just open up the patch file in a text editor.

git checkout -b mycrazybranch
[change some stuff...]
git add .
git commit -m "changed some stuff"
git format-patch master --stdout > crazy.patch
git checkout master
git apply crazy.patch --check
[all good! cleanup...]
rm crazy.patch

正如您所看到的,这将创建一个补丁文件,然后你可以用--check进行测试,看看是否有错误,然后删除补丁文件。

As you can see, this will create a patch file, you can then test it with --check and see if there are any errors, then remove the patch file.

这篇关于可以告诉我合并是否会发生冲突而不实际合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆