解决 SourceTree 中的 Git 冲突
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24156907/
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
Resolving Git conflicts in SourceTree
提问by The Dude
I was using NetBeans GIT plugin before, then I've decided to switch to SourceTree, as it is more efficient and powerful. As a newcomer to SourceTree I've managed to figure out basic Pull, Push and Commit workflows.
我之前使用过 NetBeans GIT 插件,后来我决定改用 SourceTree,因为它更高效、更强大。作为 SourceTree 的新手,我设法弄清楚了基本的拉、推和提交工作流程。
However, I got stuck when there were file conflicts when merging with my friend's work. In NetBeans if there are any conflicts, the plugin suggest to resolve it in a popup and I just want to go to the conflict resolving interface and accept the correct code chunk by clicking a button. That was simple.
但是,在与朋友的工作合并时出现文件冲突时,我陷入了困境。在 NetBeans 中,如果有任何冲突,插件建议在弹出窗口中解决它,我只想转到冲突解决界面并通过单击按钮接受正确的代码块。那很简单。
In SourceTree, there is something called External Merge Tool which didn't work well for me. When I right click on the file with conflicts, it just opened up two files side by side and there were arrows pointing left to right in the middle. There is a dropdown at the bottom of the screen to select the arrow direction.
在 SourceTree 中,有一种叫做外部合并工具的东西对我来说效果不佳。当我右键单击有冲突的文件时,它只是并排打开了两个文件,中间有从左到右的箭头。屏幕底部有一个下拉菜单,用于选择箭头方向。
I tried to use this interface to resolve conflicts, but I failed. It didn't fix the conflicts and merged two files.
我尝试使用此接口解决冲突,但失败了。它没有解决冲突并合并了两个文件。
As I searched through the internet I found that some people use external SourceTree conflict solving plugins to merge. Actually I'm little lost here. That's why I've decided to post this problem here as this might help someone like me one day.
当我通过互联网搜索时,我发现有些人使用外部 SourceTree 冲突解决插件进行合并。其实我在这里有点迷失。这就是为什么我决定在这里发布这个问题,因为这可能有一天会帮助像我这样的人。
I know there are lots of people who have been using SourceTree for a long time. Could any of them please tell me, how to resolve conflicts in SourceTree effectively?
我知道有很多人长期使用 SourceTree。他们中的任何一个都可以告诉我,如何有效地解决 SourceTree 中的冲突?
Should I use an external plugin or should I use the External Merge Tool (if so, how can I use this)?
我应该使用外部插件还是应该使用外部合并工具(如果是这样,我该如何使用它)?
回答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.
唯一的问题是,即使未选中正确的选项,它也会自动创建备份副本。
There is an alternate solutionto this problem, which uses KDiff3instead of TortoiseDiff/ TortoiseMerge.
这个问题有一个替代解决方案,它使用KDiff3而不是TortoiseDiff/ TortoiseMerge。