gitpractice.dev

brew-timer — Ch.10 · Keep your fork up to date

Exercise 2 of 6

Before you start

Forks

You cannot push to a project you are not a member of. Instead you fork it: the hosting service makes a copy of the repository under your name, which you may change freely.

Forking is a button on the website, not a git command. Yours is already made, and cloned: origin is your fork.

A second remote

A fork does not update itself. The usual setup is two remotes: origin is your fork, and `upstream` is the original project.

To update, fetch from upstream, bring its main into yours, and push the result to your fork. --ff-only makes sure your main only moves forward, without a merge commit.

git remote -v
list your remotes and their addresses
git remote add <name> <url>
remember another repository
git fetch <remote>
download its new commits
git merge --ff-only <remote>/<branch>
move your branch forward to it
git push
update your fork
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path