# Interactive Rebase — Git Fundamentals: Commits, Branches and Collaboration

Source: https://www.skillbyai.com/en/git/git-interactive-rebase

> Clean up recent commits with interactive rebase: reword, squash, reorder or drop before sharing.

## Clean up before pushing

Opens an editor listing your last 3 commits — mark each `pick`, `squash`, `reword`, or `drop`.

```bash
git rebase -i HEAD~3
```

Output:

```
pick a1b2c3d Add login form
squash 9f8e7d6 Fix typo
squash 4d5e6f7 Fix another typo
```

## Squashing fixups

Interactive rebase is great for turning "fix typo" commits into one clean commit — but only on branches you haven't shared yet.
