在我切换分支后,我应用了stash(如下所示),这导致了自动合并。
git stash apply
Auto-merging src/clojure/project_src.clj
On branch upgrade_project
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: src/clojure/project_src.clj
no changes added to commit (use "git add" and/or "git commit -a")
我尝试了恢复提交的git revert HEAD
(不是自动合并)。如何恢复自动合并?
要中止合并,您可以完成
git merge --abort
但是现在你还原了你的最后一次提交,除非你已经把这个失败的状态推到了远程,我建议重新设置你在第一个坏存储之前的位置:
git reset --hard HEAD^
此时你可以重试stash apply
并以不同方式合并,或者只是不应用存储,但无论如何你都要回到原点。
我做了以下,有效。
首先,我对恢复上一次提交的提交做了一个git revert。这让我回到了由git stash应用产生的自动合并。
然后,我应用了git reset --merge upgrade_project
,它恢复了自动合并。
编辑:我还了解到git merge --abort
和git reset --merge
的工作方式类似于正在进行的合并。