git从过去的合并中获取冲突,而无需再次运行合并 [英] git get conflicts from past merge without running merge once again

查看:60
本文介绍了git从过去的合并中获取冲突,而无需再次运行合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我合并了两个分支.有很多冲突.解决了所有问题.现在我不确定,也许我在解决冲突时犯了一个错误.而且我认为没有其他方法可以检查它是否正确—只需再次运行合并,然后逐一检查冲突即可.

I've merged two branches. Got lot's of conflicts. Resolved them all. Now I'm not sure, maybe I've made an error during conflict resolution. And I don't see no another way to check is it true — just run merge again, and check conflicts one by one.

这意味着我需要再创建一个分支来存储合并结果,对吧?

This means I need to create one more branch to store results of my merge, right?

我可以避免吗?也许可以从git的某个位置获取所有具有这些<<<<<<======>>>>>>的所有冲突文件,而无需再次运行merge?

Can I avoid it? Maybe it's possible to get all conflicting files with all these <<<<<<, ======, >>>>>> from somewhere in git, without running merge once again?

推荐答案

如果您想查看合并的内容

If you want to look at what the merge did you can do

git show <hash-of-merge-commit>

如果要重做整个合并,请执行

If you want to redo the entire merge you do

git checkout <branch-that-you-merged-to>
git reset --hard <hash-of-the-commit-just-before-the-merge>
git merge <branch-that-you-merged-in>

如果要重做合并,然后将第二个合并与第一个合并进行比较(以考虑是否更好),可以执行以下操作:

If you want to redo the merge and then compare the second merge to the first merge (to consider if it was better) you can do:

git checkout <branch-that-you-merged-to>
git rev-parse HEAD

这为您提供了当前提交的哈希值.记下来.然后做

This gives you the hash of the current commit. Note it down. Then do

git reset --hard <hash-of-the-commit-just-before-the-merge>
git merge <branch-that-you-merged-in>

完成合并,然后执行此操作以比较合并

Finish the merge, then do this to compare the merges

git difftool <hash-of-commit-noted-above>

如果您认为原始合并效果更好,可以这样做

If you felt that the original merge was better, you can do

git reset --hard <hash-of-commit-noted-above>

这篇关于git从过去的合并中获取冲突,而无需再次运行合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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