Contribute To Open Source — Keep Your Forked Repo Update To Date And In Synced

Dong Xia
3 min readSep 7, 2021

Contribute to Open Source

  1. Source Repo/Upstream Repo (where the main project is contributed to)
  2. Forked Repo/Origin Repo (a copy from the source to on your Github account)
  3. Clone Repo/Local Repo (a copy from your Github to your local PC)

There are 2 ways to keep your forked/origin repo update to date with the latest changes from the source repo.

UI Approach

  1. On your Github forked repo. Click on the Fetch upstream.
  2. Click Fetch and merge

3. Now your forked/origin repo is update to date with the source repo.

4. On your local repo main branch do a git pull to get the latest changes from your origin repo.

5. Now switch over to your feature branch git checkout <your branch name>

6. Do a git merge main to get the latest changes into your branch from the main branch.

6. Now the upstream, the origin, and the local repo are all in sync with the latest changes.

CLI Approach

  1. Add the source/upstream repo to your local repo. git remote add upstream <The Source Github URL/SSH>

2. Now your local repo you will now have a remote origin and a remote upstream.

3. In your local repo main branch or feature branch do a git pull upstream main to pull the latest changes from the source/upstream repo into your local repo.

4. Do a git push -u origin main(or feature_branch)(first time only) or git push to push the latest changes from your local repo into your forked/origin repo.

5. If you push up the feature branch. On your forked repo, do a Pull Request to merge it into your origin main.

Ready to Make the Contribution to the Open Source Repo.

  1. After pushing the feature branch onto your forked/origin repo. In your Github account go to the feature branch that you want to contribute.

2. Click on the branches next to master.

3. On the branches page. Find the branch that you want to contribute and click on the New pull request button.

4. base repo [source repo] base [main] ← head repo [origin repo] compare [feature branch]

5. Submit

--

--