Rebase local unpushed branches, interactive rebase to squash fixups, and never rebase branches others have pulled.
Rebasing without breaking the team
Local branches only
The rule is simple: never rebase a branch others have pulled. If you already pushed, merge or force-with-lease.
Interactive rebase before PR
git rebase -i mainlets you squash fixups, reorder commits, and rewrite messages. Do it before pushing.Use `--force-with-lease`
If you must force push after rebase, use
--force-with-leaseinstead of--force; it fails if someone else pushed.Rebase before merging feature to main
Keeps the main history linear: your commits land on top of main, not as a bubble.
Never rebase main
Rewriting main breaks everyone. Merge into main, never rebase main.