rebase

Moving a series of commits so they start from a different commit, by replaying each one as a new commit with a new ID.

Rebasing commits others already have gives them a conflicting history.

In more detail

git rebase main replays the current branch's own commits on top of main, so the history looks as if you started from main's latest commit and there was never a fork. The originals still exist until Git cleans them up, reachable through the reflog, but anyone who had them now has a different history. The rule: only rebase commits that exist only on your own machine; merge shared ones.

Example

git rebase main

Related terms

Taught in

References