使用 "mine" 或 "theirs" 解决 git 中的多个合并冲突的工具

Tool to resolve multiple merge conflicts in git using either "mine" or "theirs"

我有一种情况,我正在合并 git 中有多个二进制文件的变更集。通常情况下,我将使用 "Mine" 或 "Theirs" 解决更改。我的大部分日常操作都使用 TortoiseGit,但是合并冲突对话框虽然允许多个 select,但不允许多个 "resolve using theirs"。它一次只能解析一个文件。

是否有我可以用于这种特定情况的工具(select 100 多个文件并使用他们的解决)?

如果您能够使用git命令行程序,您可以为recursive合并策略指定ourstheirs选项来解析所有 冲突,分别选择"our" 更改或"their" 更改。

git merge -s recursive -X ours other-branch
# or
git merge -s recursive -X theirs other-branch

recursive 合并策略是默认的,因此您可能不必包含 -s recursive;为了完整起见,它包含在上面。)

完整的解释在 git-merge documentation:

The recursive strategy can take the following options:

ours

This option forces conflicting hunks to be auto-resolved cleanly by favoring our version. Changes from the other tree that do not conflict with our side are reflected to the merge result. For a binary file, the entire contents are taken from our side.

This should not be confused with the ours merge strategy, which does not even look at what the other tree contains at all. It discards everything the other tree did, declaring our history contains all that happened in it.

theirs

This is the opposite of ours.

图形错觉

事实上,我在 TortoiseGit 中遇到过同样的问题。它似乎更像是 缓存故障 而不是真正的错误。冲突仍出现在冲突 window 中,但在磁盘上已解决。

为了更新冲突 window,只需 杀死计算机上某处的 TortoiseGitCache.exe,即 运行,下次您检查时你的冲突:Tada!

检查的版本:1.8.16.0(Windows 8.1 / 64 位)

注意:如果直接在git命令行解析,然后用Tortoise查看缓存,也会遇到同样的问题。