【发布时间】:2015-04-13 14:35:15
【问题描述】:
我做了一个
git merge FETCH_HEAD
并且,在 git 告诉我一个文件中存在冲突之后,我做了一个
git mergetool
在我的例子中,它运行 SourceGear DiffMerge 作为 GUI 合并工具。保存合并文件后,我立即意识到我犯了一个严重的错误。我只想忘记合并并重新开始。
由于我还没有执行“git add”,更不用说提交任何东西了,我想我可以像这样轻松地删除我的错误并重做合并:
git reset FILENAME
git merge FETCH_HEAD
git mergetool
这不起作用。 “git merge”这个时候告诉我
fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.
但我当然不想提交搞砸的合并。 “git mergetool”抱怨
No files need merging
我猜我在“git reset”命令中犯了一个错误。这样做的正确方法是什么?
添加:
我做到了
git merge --abort
再说一遍:
git merge FETCH_HEAD
这个结果
error: Your local changes to the following files would be overwritten by merge: ...
git status
说:
On branch ....
Your branch is up-to-date with ......
Changes not staged for commit:
modified: nVP.ini
Untracked files:
nVP.ini.orig
no changes added to commit (use "git add" and/or "git commit -a")
只是一个想法:简单地对 nVP.ini 进行 git checkout 是否会恢复合并之前的情况?
【问题讨论】:
-
如果
nVP.ini是冲突文件,您可以只使用git checkout HEAD -- nVP.ini。git reset只是重置索引条目,你也希望工作树干净,所以检查 HEAD 版本。在合并期间你也可以git checkout --ours nVP.ini达到同样的效果,