git rebase - How to consolidate and clean-up?

5.4.3. git rebase - How to consolidate and clean-up?#

git rebase  alters the history by altering (re-)applying commits.

Interactive rebase

git rebase -i allows to combine/split/drop/edit/… the commits to reapply beforehand.

Example: git rebase:
A ── A1 ── A2          (branch A)
 \
  └─ B ── B1 ── B2      (branch B)

git rebase B A

A ── B ── B1 ── B2 ── A1' ── A2'   (branch A)
                ^
                └─ (branch B still points at B2)