Merging an Upstream Repo into your Fork

2022-12-22

This article is from Github’s help page here I am adding it here to quickly reference it when I inevitably forget how to do it.

If you don’t have push (write) access to an upstream repository, then you can pull commits from that repository into your own fork.

  1. Open Terminal.

  2. Change the current working directory to your local project.

  3. Check out the branch you wish to merge to. Usually, you will merge into master.

git checkout master
  1. Pull the desired branch from the upstream repository. This method will retain the commit history without modification.
git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME
  1. If there are conflicts, resolve them.

  2. Commit the merge.

  3. Review the changes and ensure they are satisfactory.

  4. Push the merge to your GitHub repository.

git push origin master