Git

Git Removing Upstream From Local Repository

To build a connection between the GitHub remote repository and the Git local repository, the remote URLs are used. These URLs are the path of the desired remote repository that is added as the default path for performing the pushing or pulling operations. Suppose developers push or pull any added changes to the particular remote repository while working on it. In such a situation, developers are not required to connect both repositories each time.

The outcomes of this blog are:

How to Delete Upstream From Local Repository Using “git remote remove” Command?

To remove the remote “upstream” from the local repository, the “git remote remove” command can be used. To do so, the instructions steps can be performed.

Step 1: Move to Git Repository

First, go to the required Git repository by utilizing the “cd” command:

$ cd "C:\Users\nazma\Git\test_004"

Step 2: View Remote URLs List

Next, run the “git remote” command to get the list of remote URLs through the following command:

$ git remote -v

Step 3: Remove “upstream” Remote

Then, execute the “git remote remove” command along with the remote name “upstream” to remove it from the repository:

$ git remote remove upstream

Step 4: Ensure Removed “upstream” Remote

Lastly, check the list of remote URLs to verify the specified remote name is removed:

$ git remote -v

According to the below-given output, the “upstream” remote has been successfully deleted from the local repository:

Let’s check out another way of removing the remote URLs from the Git local repository in the next section.

How to Delete Upstream From Local Repository Using “git remote rm” Command?

Another way to remove the “upstream” URL from the list is by utilizing the “$ git remote rm” command. Check out the below-provided steps for this particular purpose.

Step 1: Check Remote List

First, view the list of remote URLs using the “git remote” command:

$ git remote -v

It can be observed that the “upstream” remote name along with the remote repository URL exists:

Step 2: Remove “upstream” Remote

Next, run the following command to remove the particular remote URL:

$ git remote rm upstream

Step 3: Verify Removed Remote

Lastly, verify that the particular remote URL is removed from the Git repository:

$ git remote -v

It can be seen that the removed remote does not exist in the list:

We have efficiently described the possible ways of removing the “upstream” remote from the Git local repository.

Conclusion

To remove the “upstream” remote from the local repository, there are two commands that can be utilized, such as “$ git remote remove upstream” or “$ git remote rm upstream” commands. To remove the particular remote, first, check the remote list and then run the “$ git remote <remove>/<rm> upstream” command. This blog provided the possible ways of removing the upstream remote from the Git local repository.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.