The cursor blinks on a black screen. You type git rebase -i HEAD~3 and hit enter. Vim opens. Now it’s just you, the commit list, and precision.
Git rebase in Vim is the fastest way to rewrite history without touching a GUI. When Git launches Vim during an interactive rebase, it drops you into a temporary file listing commits in reverse order. Each line starts with a command—pick, reword, edit, squash, or fixup—followed by the commit hash and message. Change these commands to control what happens when the rebase runs.
To start an interactive rebase targeting the last three commits:
git rebase -i HEAD~3
By default, Git uses Vim as the editor unless you’ve set core.editor to something else. Inside Vim, move the cursor to the line you want. Press i to enter insert mode, edit the command, then press Esc and type :wq to save and quit. Commands matter:
pickkeeps the commit as is.rewordchanges the commit message.editpauses to let you modify the commit.squashmerges the commit into the one above, keeping both messages.fixupmerges and discards the commit message.
Effective rebase work in Vim means knowing Git’s states. If conflicts appear, Git halts the rebase. Resolve them, run git add for each fixed file, then continue with: