Three scenarios that “git rebase –onto” can solve


3 Common & Frustrating Scenarios

When using Git, your commit history can sometimes become unintentionally complex. Here are some classic scenarios that many developers have faced.

Scenario 1: Accidentally Branched from Another Feature Branch

You were supposed to create your new work branch (my-feature) from the latest main, but you accidentally branched off a colleague’s work-in-progress branch (dev-feature). Now your Pull Request includes commits that have nothing to do with your work.

Scenario 2: Mixed Multiple Features in a Single Branch

While working on a branch (work-branch), you realize that commits C and D are actually for a completely different feature (new-idea). You want to cleanly separate just these two commits into a new branch.

Scenario 3: Started New Work on an Outdated Branch

You started some new work (new-work) on a branch you created months ago (old-feature). Meanwhile, the main branch has evolved significantly, and your new commits are now sitting on top of a very old history.

All of these problems can be solved with git rebase --onto.

Continue reading Three scenarios that “git rebase –onto” can solve

A Life Summary of an Gypsy