Merging an upstream repository

03 Apr 2018

Change the current working directory to your local project.

Creating a remote called “upstream”:

git remote add upstream https://github.com/jdoe/coolapp.git
git remote -v
git fetch upstream

List all remote branches:

git branch -r

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

git checkout master

Pull the desired branch from the upstream repository. This method will retain the commit history without modification.

git pull upstream master

If there are conflicts, resolve them. For more information, see “Addressing merge conflicts”.

Commit the merge.

Review the changes and ensure they are satisfactory.

Push the merge to your GitHub repository.

git push origin master