0

macOS

I want to delete a merge commit

9d84a45 (HEAD -> staging) Merge branch 'development' into staging

I try to use git command

git rebase -i 9d84a45

Terminal shows the result and then I want to type drop 9d84a45 but I don't know how to use the editor

enter image description here

Morton
  • 5,380
  • 18
  • 63
  • 118
  • 2
    Git will use whatever editor you configure in the `core.editor` configuration setting. If you're not familiar with whichever editor it's using by default, then configure it to use one that you prefer. – larsks Apr 12 '23 at 03:26
  • 3
    This editor is called vi or vim. Look for tutorials. The escape hatch here is to type `dG` to delete all text from the current line to the end, then `:wq` to write the empty file and exit. Then configure [`core.editor`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreeditor) or [`sequence.editor`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-sequenceeditor). The reason to make the file empty is that Git takes it as a signal to abort the operation. Just quitting out without making changes does *not* abort the operation. – j6t Apr 12 '23 at 05:23
  • https://stackoverflow.com/a/2596835/7976758 – phd Apr 12 '23 at 07:51
  • 2
    Does this answer your question? [Git interactive rebase no commits to pick](https://stackoverflow.com/questions/6485508/git-interactive-rebase-no-commits-to-pick) – tripleee Apr 12 '23 at 08:14

1 Answers1

2

If that merge commit is the most recent commit on the staging branch (which the decoration 'HEAD -> staging' seems to indicate), then you do not need an interactive rebase (and its associated editor):

git switch staging
git reset --hard @~1
# done
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250