# Interactive Rebase — Git

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

> Reword, squash, or reorder recent commits before sharing them.

## 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.
