Update a GitHub Fork

How to update a GitHub forked repository with changes from the original repository.

GitHub forked repositories can be updated from GitHub UI or terminal.

To update from GitHub UI, you can create a “Pull Request” from the original repository to yours.

For updating using the terminal, add the original repo as a remote upstream to sync from.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# check that there is no remote upstream repo and add one
git remote -v
git remote add upstream https://github.com/OriginalOrgOrUser/OriginalRepo.git

# verify that upstream has been added and fetch branches and commits into upstream/master
git remote -v
git fetch upstream

# checkout fork's master branch and do a merge of upstream/master into it
git checkout master
git merge upstream/master

# push the changes to have your master branch
git push