IT lexicon › Programming › Interactive rebase (git rebase -i)

Interactive rebase (git rebase -i)

Programming På svenska → Updated: 2026-11-13

Replaying a series of commits one by one, with the option to edit, squash, reorder, or skip each one.

`git rebase -i HEAD~10` opens your editor with the last ten commits listed. You mark each `pick` to keep as-is, `squash` to merge with the previous commit, `edit` to pause and make changes, or reorder them. You save and exit, then Git replays the series with your instructions applied.

It sounds scary but it's completely safe for local work — you're working on a copy of your branch. If it goes sideways, reflog gets you back. It's invaluable for cleaning history before push; many projects require squashing development commits before a pull request is accepted.

← Back to the lexicon