So, you want to make some changes to an Open Source Repo? Good for you. That's the beauty of Open Source, even just fixing typos in the documentation makes a difference. Today I'm going to walk you through keeping your copy of a repo up to date with changes pushed to the original repo.
This tutorial assumes:
- You have a basic understanding of git
- You have a forked repo
- The original repo has changes that you want in your forked repo
Setting Up The Remote
The first thing you want to do is add the Original Repo as a remote of your Forked Repo. From the command line you want to move into your project directory and add the Original Repo's clone URL as the upstream
remote.
cd {{project_name}}
git remote add upstream {{original_repo_url}}
The Repo URL can be found on the Repo page on Github. Click on the Clone or download
button and make sure it says "Clone with HTTPS" since you don't have write access to the Original Repo.
You can verify your remotes with:
git remote -v
which should output:
origin git@github.com:{{you}}/{{project_name}}.git (fetch)
origin git@github.com:{{you}}/{{project_name}}.git (push)
upstream https://github.com/{{owner}}/{{project_name}}.git (fetch)
upstream https://github.com/{{owner}}/{{project_name}}.git (push)