See git rebase replay your branch's commits onto a new base. Understand why hashes change (c3') and the golden rule of rebasing.
Scenario
Branch state
Current step 10/10
$ git rebase main
feature's commits are replayed on top of main. c3 and c4 are abandoned and identical c3', c4' appear — that's why hashes change. You get linear history, but never rebase a branch others have pulled.
$ git log --oneline --all
c4' (HEAD -> feature) feat B
c3' feat A
c5 (main) hotfix
c2 base feature
c1 init
File content (at HEAD) — app.js @ feature
Circles are commits; dimmed circles were abandoned by rebase/reset. A prime (c3') means same content, rewritten hash. In sandbox mode, run commands yourself with the buttons.
git rebase replays your branch's commits on top of another branch's tip. Your feature commits are restacked onto the newest main, producing a straight line — as if you'd started from the latest main all along.
The commits are copied, not moved. The originals are abandoned and new commits with the same content but different parents appear — shown as c3' in the simulator. Since a commit's hash is computed from content plus parent, every rebased commit gets a new hash.
That's the golden rule: never rebase a shared branch. If teammates have your old commits and you rewrite them, their history and yours diverge and everything tangles. Rebase is safe only for local branches you haven't pushed. Git Branch Simulator