Skip to main content
Senior

Selective Rebase

Senior

Task

While on bugFix, move the last four commits of this branch (C2-C5) directly onto the tip of main.

Requirements

  • Select a range that starts after HEAD~4.
  • Use main as the new base.
  • Apply a selective rebase with --onto.

Expected result

The bugFix branch must end with a rewritten chain of four commits on top of main. HEAD must stay on bugFix.

What you will learn

After completing the task, you will be able to:

  • specify the old and the new base for a rebase;
  • move only a selected section of history;
  • use --onto for complex graph restructuring.
Goal
localC0C1mainC2C2'C3C3'C4C4'C5C5'HEAD bugFix
Git trainer0 commands
terminal
localC0C1mainC2C3C4C5HEAD bugFix