How to fork and keeping your github repo in sync

Reading time ~1 minute

Forking a Github Repository

Just click “fork” button on upper right corner

black tea

Making a Local Clone

$ git clone https://github.com/YOUR_USERNAME/YOUR_FORK.git

Adding a Remote

# list current configured remote repository for your fork
$ git remote -v

# add upstream
$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

# list again to see upstream is added
$ 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)

Working in a Branch

Create and checkout a feature branch. Personally, I like to set github issue number followed by summary of issue. This notation GH-${issue_num} will create a link to the issue on github.

$ issue_num=100
$ git checkout -b GH-${issue_num}_summary_of_issue

When ready, commit and push changes to GitHub.

$ git push origin GH-${issue_num}_summary_of_issue

Keeping Your Fork in Sync

$ git pull upstream master
$ git push origin master

Cheers!

Imogene Run

# Breathing Through the Sky: My Imogene Pass Run![Start line](../images/2025-09-07/start.jpeg)This weekend I had the privilege of lining ...… Continue reading

Running Post Hysterectomy

Published on April 01, 2023

Refinance

Published on February 19, 2021