git 仅重做单个文件的合并
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6857082/
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
Redo merge of just a single file
提问by hammar
I'm in the middle of a large merge, and I've used git mergetool
to resolve all the conflicts, but I have not committed yet, as I wanted to make sure the merge was ok first.
我正在进行大型合并,我曾经git mergetool
解决过所有冲突,但我还没有提交,因为我想先确保合并没问题。
It turns out that I made a mistake while resolving the conflicts in one file, and I would like to redo the conflict resolution with git mergetool
on that file. As this is a large merge I would like to avoid redoing the merge on all the other files, as I understand I would have to do with git merge --abort
.
结果是我在解决一个文件中的冲突时犯了一个错误,我想重新解决git mergetool
该文件中的冲突。由于这是一个大型合并,我想避免对所有其他文件重做合并,因为我知道我将不得不处理git merge --abort
.
I know I could just edit the file manually, but this would be quite tedious and it would be much easier to just redo the git mergetool
operation. Is this possible?
我知道我可以手动编辑文件,但这会很乏味,而且重做git mergetool
操作会容易得多。这可能吗?
回答by hammar
It seems I was just looking in the wrong place. The solution turned out to be quite simple.
看来我只是找错了地方。结果证明解决方案非常简单。
git checkout -m <file>
This returns the file to its conflicted state. I can then run git mergetool
to redo the merge.
这会将文件返回到其冲突状态。然后我可以运行git mergetool
以重做合并。
回答by ?imon Tóth
You can always edit the files manually.
您始终可以手动编辑文件。
If you are using the git merge --no-commit
, then you will simply have a prepared commit (after the auto and semi-auto) merge.
如果您使用的是git merge --no-commit
,那么您将只需要一个准备好的提交(在自动和半自动之后)合并。
You can still safely edit the files and only commit when completely satisfied.
您仍然可以安全地编辑文件,并且只有在完全满意时才提交。