Integrating changes.
WHAT MERGING DOES
Combines two branches, creating a commit with two parents.
What it preserves: the actual history, including when work happened in parallel.
WHAT REBASING DOES
Replays your commits on top of another branch, as if written afterwards.
What it produces: a linear history, easier to read.
WHAT IT CHANGES
The commits themselves, giving them new identities.
WHAT THE RULE IS
Never rebase commits that others have already pulled.
WHY
Their history and yours diverge, and recovering is painful.
WHAT IS SAFE
Rebasing your own unshared branch onto the latest main.
WHAT SQUASHING DOES
Combines several commits into one.
When it helps: cleaning up a series of small work-in-progress commits before merging.
WHAT IT LOSES
The detail of how the work developed.
WHAT TO ESTABLISH IN A TEAM
Which approach is used, and apply it consistently.
WHAT TO DO BEFORE MERGING
Integrate the latest main, and resolve conflicts on your branch.
WHY
So conflicts are resolved by the person who understands the change.