Use merge when you want to preserve the true shape of history, and rebase when you want a clean straight line. Both combine work from two branches; they just record it differently.
Merge creates a new commit that ties two branch tips together. Nothing moves, so the record stays honest about when work diverged. Rebase instead replays your commits on top of the other branch, as if you had started from its latest state.
A simple rule works well. Rebase your own local branch to tidy it before sharing. Merge when combining branches other people already pulled. The danger is rebasing shared commits, which rewrites history others depend on and creates painful duplicates. When unsure, merge is the safer default.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.