interactive rebase
A rebase that first opens a todo list in your editor, letting you reorder, reword, squash or drop commits before they are replayed.
In more detail
git rebase -i HEAD~3 lists the last three commits oldest first. You change the word in front of each line, save and close, and Git replays them your way, pausing when it needs a new message or hits a conflict. Use it to tidy local work before sharing, never on commits others have.
Example
git rebase -i HEAD~3Related terms
- rebase — Moving a series of commits so they start from a different commit, by replaying each one as a new commit with a new ID.
- rebase todo list — The text file an interactive rebase opens, one line per commit, where the first word says what to do with that commit.
- squash — Combining several commits into one, for example small fix-up commits into the commit they fix.
- rewriting history — Replacing existing commits with new ones, for example with amend, rebase or reset, which gives them new IDs.
Taught in
- Interactive Rebase: Squash, Reorder, Reword — Advanced Git Internals & Distributed Workflows