Git: Sync fork with upstream changes

A forked repository can be synced with the upstream one as follows:

  1. Clone the forked repository locally if not already done.
git clone https://github.com/OWNER/FORKED-REPOSITORY.git
  1. List the remote repository configured for your fork:
git remote -v
  1. Add a new remote upstream repository that will be synced with the local fork:
git remote add upstream https://github.com/OWNER/REPOSITORY.git
  1. Verify the configured remote repository for your fork:
git remote -v
  1. Pull the latest changes from upstream remote:
git fetch upstream
  1. Checkout to your local master branch of the forked repository:
git checkout master
  1. Merge upstream/master to local master branch:
git merge upstream/master
  1. Commit and push your changes to remote fork:
git commit -m 'merged with upstream changes'
git push