Interactive rebase lets a developer improve the shape of unpublished history. It is useful for combining fixup commits, correcting messages, and separating unrelated work before review.
Know when it is safe
Rewriting commits changes their identifiers. It is generally appropriate for a local branch that has not been shared. Rewriting a branch that teammates have based work on can force confusing recovery steps.
Agree on repository policy before rewriting published history. Protected branches should not be rewritten.
Use the todo list deliberately
Interactive rebase can pick, reword, edit, squash, or fixup commits. Read the planned sequence before saving it. When combining commits, ensure the resulting message accurately describes the complete change.
Run the relevant tests after conflict resolution and before pushing the rewritten branch.
Recover carefully
Git records previous branch positions in the reflog for a period of time. If a rebase goes wrong, stop and inspect the current state rather than running additional destructive commands blindly. Create a backup branch before complex history edits.
Checklist
- Rewrite only history your team agrees is unpublished.
- Create a backup reference before risky edits.
- Review the rebase todo list.
- Resolve conflicts and rerun tests.
- Coordinate before force-pushing shared branches.