git:如何重做合并冲突解决(在提交合并之前)?

git:如何重做合并冲突解决(在提交合并之前)?,git,merge,Git,Merge,我做了一个测试 git merge FETCH_HEAD 在git告诉我一个文件中存在冲突后,我做了一个 git mergetool 在我的例子中,它作为GUI合并工具运行SourceGear DiffMerge。保存合并文件后,我立即意识到我犯了一个严重的错误。我只想忘记合并,重新开始 因为我还没有执行“git add”,更不用说提交任何东西了,我想我可以像这样轻松地删除错误并重新进行合并: git reset FILENAME git merge FETCH_HEAD git merge

我做了一个测试

git merge FETCH_HEAD
在git告诉我一个文件中存在冲突后,我做了一个

git mergetool
在我的例子中,它作为GUI合并工具运行SourceGear DiffMerge。保存合并文件后,我立即意识到我犯了一个严重的错误。我只想忘记合并,重新开始

因为我还没有执行“git add”,更不用说提交任何东西了,我想我可以像这样轻松地删除错误并重新进行合并:

git reset FILENAME
git merge FETCH_HEAD
git mergetool
这是行不通的。“git合并”这个时候告诉我

fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.
但我当然不想搞砸合并。“git合并工具”抱怨

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
说:


只是一个想法:简单地对nVP.ini进行git签出是否会在合并之前恢复情况?

要在提交前撤消错误的冲突解决方案,
git checkout-m--$thefile

$ git merge 3fac3
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
Automatic merge failed; fix conflicts and then commit the result.
$ vi file.txt         # fix all the conflicts. do it wrong.
$ git add file.txt    # <--- ooops
$ git checkout -m -- file.txt    # <--- the correct un-oops-ifier here

如果
nVP.ini
是冲突文件,您可以只
git签出头--nVP.ini
git reset
只需重置索引项,您还需要清理工作树,因此请签出HEAD版本。在合并过程中,您还可以
git checkout--ours nVP.ini
出于同样的效果,这只会导致
错误:pathspec'xxx'与git已知的任何文件都不匹配。
error.Krzaku如果git能够找到该文件,您将需要输入git状态显示的路径@谢谢你的回答,你为我节省了大约4个小时。
$ git merge 3fac3
Auto-merging file.txt
CONFLICT (content): Merge conflict in file.txt
Automatic merge failed; fix conflicts and then commit the result.
$ vi file.txt         # fix all the conflicts. do it wrong.
$ git add file.txt    # <--- ooops
$ git checkout -m -- file.txt    # <--- the correct un-oops-ifier here
git checkout -m --conflict diff3 -- file.txt