Today I learned
Read about some cool stuff.
git rebase --onto
06 sie 2025

git rebase --onto allows you to change the base of a range of commits to a new starting point. It's especially useful when you want to move a feature branch to begin from a different commit, excluding unwanted or conflicting history - for example, when the original base branch has been rewritten or modified.

A---B---C---D---E  (main)
     \
      F---G---H  (feature)

To rebase feature (F, G, H) onto commit C:

git checkout feature
git rebase B --onto C
A---B---C---D---E  (main)
         \
          F---G---H  (feature)

You can think about this as:

Take feature commits after B and replay them onto C

# from
A---B---C---D---E  (main)
A---B---F---G---H  (feature)
    ↑   └────────
        Take this

# to

A---B---C---D---E  (main)
A---B---C---F---G---H  (feature)
        ↑   └────────
        Move onto C
ul. Powstańców Warszawy 5
15-129 Białystok
+48 668 842 999
SKONTAKTUJ SIĘ Z NAMI