Show current remote repositories:
git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
Add original repository you forked from to your local repository:
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Now you should find the original repository as upstream
:
git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
Add commits from the original repository to your fork
git fetch upstream
git checkout mybranch
git merge upstream/mybranch
If the original repository has an onpen pull request you want to add to your code base you can directly merge it into a branch of your fork:
git pull upstream pull/<PR-ID>/head