Skip to main content
Junior

Rebase in Git

Junior

Task

Create diverging changes in main and bugFix, then move the work from bugFix on top of the up-to-date main using rebase.

Steps

  1. Create the bugFix branch and make one commit in it.
  2. Go back to main and make one separate commit.
  3. Switch back to bugFix.
  4. Rebase the bugFix branch onto main.

Expected result

The commit from bugFix must be copied on top of the tip of main. The history becomes linear, no merge commit should appear, and HEAD stays on bugFix.

What you will learn

After completing the task, you will be able to:

  • tell rebase apart from merge;
  • move commits onto a new base;
  • understand why a commit gets a new identifier after a rebase.
Goal
localC0C1C2C3mainC2'HEAD bugFix
Git trainer0 commands
terminal
localC0C1HEAD main