Pull new updates from original GitHub repository into forked GitHub repository
You have to add the original repository (the one you forked) as a remote.
From the GitHub documentation on forking a repository:
Once the clone is complete your repo will have a remote named “
origin
” that points to your fork on GitHub.
Don’t let the name confuse you, this does not point to the original repo you forked from. To help you keep track of that repo we will add another remote named “upstream”:$ cd PROJECT_NAME $ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git $ git fetch upstream # then: (like "git pull" which is fetch + merge) $ git merge upstream/master master # or, better, replay your local work on top of the fetched branch # like a "git pull --rebase" $ git rebase upstream/master
There's also a command-line tool (gh
) which can facilitate the operations above.
Here's a visual of how it works:
See also "Are Git forks actually Git clones?".
In addition to VonC's answer, you could tweak it to your liking even further.
After fetching from the remote branch, you would still have to merge the commits. I would replace
$ git fetch upstream
with
$ git pull upstream master
since git pull is essentially git fetch + git merge.