Let's say I want to undo the last-but-one commit in my working tree only, and all my commits have already been pushed. Usually I use git revert -n <HASH>
(see this answer). However, if that will cause conflicts due to changes made in the most recent commit, it will ask me to resolve the conflicts as normal when merging. Once conflicts are resolved and git add
the files, I can't git revert -n --continue
because I get error fatal: revert: --no-commit cannot be used with --continue
. So instead just use git revert --continue
but this causes a commit, even though I originally specified the -n
option before committing, it's now ignored after the merge.
How do I avoid the commit being done after merge is completed?