How to Fork Your Own GitHub Repository and Configure Upstream

Simon Huang

Simon Huang

@simon

When you want to use one of your existing repositories as a template for a new project—while still maintaining a link to the original for updates—a standard “fork” isn’t always possible on GitHub if you own both. Here is the best practice steps to manually fork your own repo and configure an upstream remote.

1. Clone the Source Repository

First, clone the repository you want to use as your “template” or source. Specify a new directory name to keep things organized.

git clone https://github.com/[yourname]/template-repo.git new-project
cd new-project

2. Create the New Repository on GitHub

Before pushing, you need a destination.

  1. Log in to GitHub and go to github.com/new.
  2. Enter your New Project Name.

    Important: Do not initialize the repository with a README, license, or .gitignore, as you will be pushing an existing history.

3. Reconfigure Remotes

Currently, your local folder points to the old template-repo. You need to point origin to your new project.

# Remove the link to the original repository
git remote remove origin

# Link to your newly created GitHub repository
git remote add origin https://github.com/[yourname]/new-project.git

4. Push the Code to the New Repository

Now, upload your code to the new destination. Using the -u flag sets up “tracking,” so future pushes are simpler.

git push -u origin main

5. Configure the Upstream Remote

To pull future updates or bug fixes from your original “template” repo into your new project, add it as an upstream remote.

git remote add upstream https://github.com/[yourname]/template-repo.git

How to Sync Changes from Upstream

Now that you are configured, if you update template-repo and want those changes in new-project, run:

  1. Fetch the updates: git fetch upstream
  2. Merge them: git merge upstream/main
  3. Push to your new repo: git push origin main
Fizzy

© 2025 Fizzy All Rights Reserved.