如何在git pull之后解决冲突? [英] How do I resolve a conflict after git pull?

查看:1286
本文介绍了如何在git pull之后解决冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在 git pull 后解决一些冲突。

I have to solve some conflict after a git pull.

$ git pull
CONFLICT (rename/add): Renamed vignette_generator_mashed.h->vision_problem_8.h in 49423dd0d47abe6d839a783b5517bdfd200a202f. vision_problem_8.h added in HEAD
Added as vision_problem_8.h~HEAD_1 instead
Removed vignette_generator_cross_square.cc
Automatic merge failed; fix conflicts and then commit the result.

所以我用google搜索了一下,发现有人用 git mergetool 。但这里是我得到的:

So I googled it a bit, and found people saying using git mergetool. But here is what I got:

$ git mergetool
merge tool candidates: meld kdiff3 tkdiff xxdiff meld gvimdiff emerge opendiff emerge vimdiff
No files need merging
$ git mergetool opendiff
merge tool candidates: meld kdiff3 tkdiff xxdiff meld gvimdiff emerge opendiff emerge vimdiff
opendiff: file not found

这是否意味着我必须安装一些东西?

So does it mean I have to install something?

如果我只想从 git pull 的版本覆盖所有内容?

What if I simply want the version from git pull to overwrite everything?

推荐答案

你不需要mergetool。

You don't need mergetool for this. It can be resolved pretty easily manually.

您的冲突是您的本地提交添加了一个文件 vision_problem_8.h ,通过从 vignette_generator_mashed.h 重命名,还创建了一个远程提交。如果你运行 ls -l vision_problem_8.h * ,你可能会看到git为你保存的这个文件的多个版本。其中一个将是你的,另一个将是远程版本。您可以使用编辑器或任何您喜欢的工具来解决冲突的内容。完成后, git add 受影响的文件并提交以完成合并。

Your conflict is that your local commits added a file, vision_problem_8.h, that a remote commit also created, by a rename from vignette_generator_mashed.h. If you run ls -l vision_problem_8.h* you will probably see multiple versions of this file that git has preserved for you. One of them will be yours, another of them will be the remote version. You can use an editor or whatever tools you like to resolve the conflicting contents. When you're done, git add the affected files and commit to complete the merge.

如果您只是想要使用远程提交的版本,那么您可以将未写入的副本移动到位并 git add

If you just want to use the remote commit's version, then you can just move the copy that you didn't write into place and git add it.

关于合并工具,看看 git help mergetool 。基本上,它会尝试运行每个包含的可能性,直到它找到一个,或者使用一个已明确配置的可能。

Regarding the merge tools, have a look at git help mergetool. Basically, it's going to try running each of the included possibilities until it finds one, or use one you have explicitly configured.

这篇关于如何在git pull之后解决冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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