Open source contribution

Stage 2 · Lesson 5 of 7

Keeping a branch up to date with rebase

Git and GitHub for contributors

Upstream keeps moving while your is open. To bring your branch up to date, run git fetch upstream, then git rebase upstream/main while on your branch. replays your commits on top of the latest upstream work.

The result is a straight history with no merge commits, which many projects require. matters too. Update your fork's main with git switch main, git merge --ff-only upstream/main and git push origin main, or use GitHub's Sync fork button.

Rebase rewrites your commits, creating new copies of them. That is fine on your own , and wrong on a branch other people build on. Some projects prefer merging main into the branch instead, so follow the .

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with

  • BookFree
    Pro Git

    Scott Chacon and Ben Straub

    Chapters 3, 5 and 6: branching, contributing to a project, and GitHub forks

Practise

  • The remote levels drill fetch, rebase and pushing while you watch the commit graph

Keep handy

Also worth your time

Mark this stage as not done?