简体   繁体   English

如何使用Eclipse git merge工具进行“我们的”合并?

[英]How to do an “ours” merge using the Eclipse git merge tool?

I'm trying to do a merge where I have conflicts and one file has diverged massively. 我正在尝试合并,我有冲突,一个文件大量分歧。 The eclipse git merge tool is great for small changes, but one of my files is large and has hundreds of explicitly marked conflicting sections. eclipse git merge工具非常适合小的更改,但我的一个文件很大,并且有数百个明确标记的冲突部分。 I can't for the life of me find an easy way to just do a merge using the "ours" strategy of just using my version and abandoning the remote version. 我不能为我的生活找到一个简单的方法来使用我们的“我们的”策略只使用我的版本并放弃远程版本进行合并。

On Linux or Mac it would be easy for me to just do it from the command line, but I'm on a corporate Windows computer and don't have command-line git. 在Linux或Mac上,我很容易从命令行执行此操作,但我在公司的Windows计算机上并且没有命令行git。 I even tried the workaround of doing "replace with" -> "Head revision" from the file's context menu in the package explorer, but that action is disabled since the repository is in merge conflict mode. 我甚至尝试了从包浏览器中的文件的上下文菜单中执行“替换为” - >“头部修订”的解决方法,但由于存储库处于合并冲突模式,因此该操作被禁用。 This would be an ok solution, but it would still be preferable to have a clear way of applying "ours" or "theirs" strategies to entire files from the merge tool. 这将是一个很好的解决方案,但是仍然可以更好地将“我们的”或“他们的”策略应用于合并工具中的整个文件。

I had to resort to a hard reset, making a copy of my file, doing the merge, and then replacing the merged version with my clean copy. 我不得不求助于硬重置,制作我的文件的副本,进行合并,然后用我的干净副本替换合并的版本。 Am I missing a much easier way of doing this? 我错过了一个更简单的方法吗?

In the editor of the merge tool, you can edit the left section. 在合并工具的编辑器中,您可以编辑左侧部分。

After clicking on Merge Tool, select the "HEAD" option in the dialog that appears, then the left section will contain the same content as HEAD. 单击合并工具后,在出现的对话框中选择“HEAD”选项,然后左侧部分将包含与HEAD相同的内容。

So when the left section is already good, just make a small modification, undo it and then save. 因此,当左侧部分已经很好时,只需做一个小修改,撤消它然后保存。 The modification is necessary because save is not available from the beginning. 修改是必要的,因为从一开始就无法保存。

现在有一个条目“替换为”,允许您在Git Staging视图中的文件的上下文菜单中选择“我们的”或“他们的”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM