Back to roadmap

Lesson 08

Rebase

Rebase moves your branch's work onto a newer base by replaying its commits.

Visual Explanation

Ready to run git rebase main.

Keep These Ideas

New base
Your feature begins from the latest point on main.
Replayed commits
Git creates new versions of your feature commits with new IDs.
Private history
Rebase work you have not shared; avoid rewriting teammates' history.

The Real Command

Terminal
git rebase main

From feature/login, git rebase main replays your feature commits after the newest commit on main.

Command Details

git rebase --continue

--continue resumes a paused rebase. Resolve a conflict and stage the fix before continuing the replay.

git rebase -i HEAD~3

-i means interactive. It lets you reorder, combine, or rename your last three unpublished commits.

git rebase --abort

--abort returns to the starting point. Use it when a rebase is not going as planned.

Knowledge Check

Replay Work on a New Base

Build a linear history while recognizing when rewriting commits is risky.

Question 1 of 5

  1. Question 1: current
  2. Question 2: not started
  3. Question 3: not started
  4. Question 4: not started
  5. Question 5: not started
Command Challenge

You are on your unpublished feature branch. Replay its commits on top of the latest main.