Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

How do you keep a forked repository up to date with the original project?

SHORT ANSWER

Add the original repo as a second remote called upstream, fetch it, merge or rebase upstream/main into your main, and push to your fork. GitHub also has a Sync fork button for the same job.

Explain it simply

Your fork is a photocopy of a book. The original author keeps adding pages, and your copy does not update itself.

Once you add upstream, the sequence is fetch, bring it into your local main, and push. If you never commit to your fork's main, this is always a fast-forward. Do your own work on feature branches so that main stays a clean mirror. In the browser, the Sync fork button on your fork's page does the same without a terminal.

Example

bash
git remote add upstream https://github.com/original/project.git
git fetch upstream
git switch main
git merge --ff-only upstream/main
git push origin main

What to say in the interview

"I add the original repo as an upstream remote, fetch it, update my local main from upstream/main, and push to my fork. I keep my own work on feature branches so main stays a clean mirror, or I use GitHub's Sync fork button."

#git#fork#upstream

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.