The Golden Rule of Rebase
Never rebase shared commits.
Rebase creates new commits, and throws away the old ones. That's fine for commits only you have. But if teammates already have the old commits, rebasing causes chaos.

- Rebase replaces commits
- Fine if only you have them
- Chaos if others do
The golden rule
So here's the golden rule. Never rebase commits that other people have already pulled. Rebase your own local work as much as you like. But once commits are on a shared branch like main, leave them alone, and use merge or revert instead.
When to use which
In practice, many people rebase their own feature branch onto main, to keep it fresh, before opening a pull request. Then the pull request is merged normally. That way, you get a clean history, and nobody's work is ever rewritten.
Rebase
- Your own feature branch
- Before opening a PR
- To catch up with main
Merge
- Shared branches
- Merging pull requests
- When unsure
Summary
Never rebase commits others already have. Rebase your own work, merge shared work. Next, rewriting your own recent commits, before you share them.
Key takeaways- Never rebase shared commits
- Rebase your own branch
- Merge shared work