Add Upstream after Cloning the Original Repo

Step 1: Clone the Original Repository

If you haven’t already cloned the original repository, start by cloning it to your local machine using the git clone command. Replace <original_repository_url> with the URL of the original repository:

git clone <original_repository_url>

for example,

git clone https://github.com/TuringLang/Turing.jl.git

Step 2: Navigate to Your Cloned Repo

Change directory into your cloned repository. If you’ve already cloned original repo, navigate to its directory using the cd command:

cd <your_cloned_directory>

for example,

cd Turing.jl

Now the names of remote repositories using:

git remote -v

Step 3: Add Upstream Remote

When you clone the original repository then the name of your original clone repo is `origin`, so just change the name of your cloned repo to `upstream` using:

git remote rename origin upstream

Now you cloned repository is an upstream but you cannot directly push the changes into that if you are working with any project that you do not have write access to so now you have to add your forked repository as an origin using:

git remote add origin <forked_repo_link>

for example,

git remote add origin https://github.com/shravanngoswamii/Turing.jl.git

Step 4: Verify Upstream Remote

You can verify that the upstream remote has been added correctly by listing the configured remotes using the git remote -v command:

git remote -v

How to Add Upstream in Git?


How to Add Upstream in Git?

When you fork a repository, you create a copy of it under your own account. However, as the original repository updates with new features, bug fixes, and improvements, you’ll want to keep your forked repository up-to-date with these changes. This is where adding an upstream remote in Git comes into play. In this article, we’ll explore the process of adding an upstream remote to your forked repository, fetching changes from the original repository, and keeping your fork synchronized with the latest updates.

Table of Content

  • What is upstream?
  • How to Add Upstream in Git?
  • Add Upstream after Cloning the Original Repo

Similar Reads

What is upstream?

The upstream repository is the original project repository from which your repository was forked or cloned. It’s the official source where the project is maintained and updated. When you fork a repository on platforms like GitHub, GitLab, or Bitbucket, the original repository becomes your upstream repository....

How to Add Upstream in Git?

Adding an upstream repository in Git involves configuring your local repository to recognize and fetch changes from the original project repository. Here’s a step-by-step guide to adding an upstream repository:...

Add Upstream after Cloning the Original Repo

Step 1: Clone the Original Repository...