Skip to main content
Senior

Fetch and Rebase

Senior

Task

The local main and main on origin have diverged: each has gained its own commit. Keep the history linear by moving the local work on top of the remote work.

Steps

  1. Download the current state of origin.
  2. Rebase the local main onto o/main.

Constraint

Do not use merge: the resulting history must not contain a merge commit.

Expected result

The remote commit must become the base, and the local one must be a new copy on top of it. HEAD must stay on main.

What you will learn

After completing this task you will be able to:

  • detect a divergence between the local and remote history;
  • combine fetch and rebase;
  • keep the history linear when working together.
Goal
localC0C1C2C3o/mainC2'HEAD main
originC0C1C3HEAD main
Git trainer0 commands
terminal
localC0C1o/mainC2HEAD main
originC0C1C3HEAD main