如何以交互方式(视觉上)解决 SourceTree / git 中的冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16800280/
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
How to interactively (visually) resolve conflicts in SourceTree / git
提问by Nullptr
I'm using (Windows) SourceTree for my git project. I can do it in either command prompt or Linux terminal.
我正在为我的 git 项目使用 (Windows) SourceTree。我可以在命令提示符或 Linux 终端中执行此操作。
But, I'm wondering whether there is a nice way to interactively and visually resolve conflicts. For example, if pull detects conflicts, popping up a GUI-based conflict tool (e.g., P4Merge). Is it possible?
但是,我想知道是否有一种很好的方式来交互式和可视化地解决冲突。例如,如果 pull 检测到冲突,则弹出一个基于 GUI 的冲突工具(例如,P4Merge)。是否可以?
I am always doing manual conflict resolving, which is just painful.
我总是在手动解决冲突,这很痛苦。
This is, for example, a git pull
message, from SourceTree.
例如,这是pull
来自 SourceTree的 git消息。
git -c diff.mnemonicprefix=false -c core.quotepath=false pull --no-commit origin master
From W:\repo\
* branch master -> FETCH_HEAD
Updating 33c07bf..41e0249
error: Your local changes to the following files would be overwritten by merge:
foo.cpp
goo.cpp
goo.hpp
Please, commit your changes or stash them before you can merge.
Aborting
Completed with errors, see above.
回答by gtrig
From SourceTree, click on Tools->Options. Then on the "General" tab, make sure to check the box to allow SourceTree to modify your Git config files.
在 SourceTree 中,单击“工具”->“选项”。然后在“常规”选项卡上,确保选中该框以允许 SourceTree 修改您的 Git 配置文件。
Then switch to the "Diff" tab. On the lower half, use the drop down to select the external program you want to use to do the diffs and merging. I've installed KDiff3and like it well enough. When you're done, click OK.
然后切换到“差异”选项卡。在下半部分,使用下拉菜单选择要用于进行差异和合并的外部程序。我已经安装了KDiff3并且非常喜欢它。完成后,单击“确定”。
Now when there is a merge, you can go under Actions->Resolve Conflicts->Launch External Merge Tool.
现在,当有合并时,您可以在 Actions->Resolve Conflicts->Launch External Merge Tool 下进行。
回答by trejder
I'm using SourceTree along with TortoiseMerge/Diff, which is very easy and convinient diff/merge tool.
我将 SourceTree 与 TortoiseMerge/Diff 一起使用,这是非常简单方便的 diff/merge 工具。
If you'd like to use it as well, then:
如果你也想使用它,那么:
Get standalone version of TortoiseMerge/Diff (quite old, since it doesn't ship standalone since version 1.6.7 of TortosieSVN, that is since July 2011). Links and details in this answer.
Unzip
TortoiseIDiff.exe
andTortoiseMerge.exe
to any folder (c:\Program Files (x86)\Atlassian\SourceTree\extras\
in my case).In SourceTree open
Tools > Options > Diff > External Diff / Merge
. SelectTortoiseMerge
in both dropdown lists.Hit
OK
and point SourceTree to your location ofTortoiseIDiff.exe
andTortoiseMerge.exe
.
获取 TortoiseMerge/Diff 的独立版本(很旧,因为它从 TortosieSVN 的 1.6.7 版开始不再独立发布,即自 2011 年 7 月以来)。此答案中的链接和详细信息。
解压缩
TortoiseIDiff.exe
并TortoiseMerge.exe
到任何文件夹(c:\Program Files (x86)\Atlassian\SourceTree\extras\
在我的情况)。在 SourceTree 打开
Tools > Options > Diff > External Diff / Merge
.TortoiseMerge
在两个下拉列表中选择。点击
OK
SourceTree 并将其指向您的TortoiseIDiff.exe
和位置TortoiseMerge.exe
。
After that, you can select Resolve Conflicts > Launch External Merge Tool
from context menu on each conflicted file in your local repository. This will open up TortoiseMerge, where you can easily deal with all the conflicts, you have. Once finished, simply close TortoiseMerge (you don't even need to save changes, this will probably be done automatically) and after few seconds SourceTree should handle that gracefully.
之后,您可以Resolve Conflicts > Launch External Merge Tool
从本地存储库中每个冲突文件的上下文菜单中进行选择。这将打开 TortoiseMerge,您可以在其中轻松处理所有冲突。完成后,只需关闭 TortoiseMerge(您甚至不需要保存更改,这可能会自动完成),几秒钟后 SourceTree 应该会优雅地处理它。
The only problem is, that it automatically creates backup copy, even though proper option is unchecked.
唯一的问题是,即使未选中正确的选项,它也会自动创建备份副本。
回答by ozkary
When the Resolve Conflicts->Content Menu are disabled, one may be on the Pending files list. We need to select the Conflicted files option from the drop down (top)
当解决冲突->内容菜单被禁用时,一个可能在待处理文件列表中。我们需要从下拉列表(顶部)中选择冲突文件选项
hope it helps
希望能帮助到你