After I switched branches, I applied stash (as below), which resulted in an auto-merge.
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")
I tried git revert HEAD
which reverted a commit (not the auto-merge). How can I revert the auto-merge?
To abort the merge, you could have done
git merge --abort
But now that you reverted your last commit, and unless you already pushed that failed state to remote, I'd suggest reseting to the point where you were before the first bad stash :
git reset --hard HEAD^
At this point you can retry the stash apply
and merge it differently, or just not apply the stash, but in any case you're back to square one.
I did the following, which worked.
First, I did a git revert on the commit that reverted my last commit. Which brought me right back to the auto-merge that resulted from the git stash apply.
Then, I applied git reset --merge upgrade_project
which reverted the auto-merge.
Edit : I also learned that git merge --abort
and git reset --merge
both work similarly for a merge that is in progress.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.