Stage 2 · Lesson 5 of 7
Keeping a branch up to date with rebase
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
- BookFreePro Git
Scott Chacon and Ben Straub
Chapters 3, 5 and 6: branching, contributing to a project, and GitHub forks