Git

How to Remove Remote Origin from a Git Repository

Origin” is the default shorthand name of the remote repository that is created whenever developers clone a repository. Git remote points to the remote version of the repository. It is a built-in connection to the remote repository on a Hosting server named GitHub. When developers collaborate with team members on a large project, it is utilized for creating more than one Git remote. Moreover, Git users can add new or set the existing remotes.

This post will discuss:

Let’s get started!

Method 1: How to Delete Git Remote Origin from Repository Using git remote rm origin Command?

To remove the remote origin from a Git repository, first, switch to the Git repository and check the remote list. Then, run the “$ git remote rm origin” command and verify it by executing the “$ git remote -v” command.

Now, move ahead and understand the stated procedure through implementation!

Step 1: Navigate to Git Repository

Move to the Git directory where the desired local repository is located:

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

Step 2: Check Remote Connections

Next, run the “git remote” command with the “-v” option to list the existing remote connections:

$ git remote -v

Step 3: Remove Remote Origin

Now, remove the remote origin by executing the following command:

$ git remote rm origin

Step 4: Verify Remote List

Lastly, run the following command to ensure that the remote origin has been removed successfully:

$ git remote -v

Let’s move to the next method to delete the Git remote origin from a local repository.

Method 2: How to Delete Git Remote Origin from Repository Manually?

You can also delete the Git remote origin from the repository by utilizing the configuration file. To do so, first, open the configuration file utilizing the text editor and delete the remote origin manually. Then, run the “$ git remote -v” command for verification.

Follow the below instructions to perform the stated steps!

Step 1: Open Configuration File

First, open the Git configuration file in your favorite text editor. For instance, we have used the nano text editor to do so:

$ nano .git/config

Step 2: Delete Remote

Now, remove the below-highlighted lines from the configuration file and save the added changes by pressing “CTRL+S”:

After doing so, press “CTRL+X” to exit.

Step 3: Check Remote Connections

Next, list the remote connections by utilizing the following command:

$ git remote -v

That’s all! We have offered the method to delete the Git remote origin from the repository.

Conclusion

There are two ways to remove the remote origin from a Git repository: using the “$ git remote rm origin” command or manually by utilizing the configuration file. To do so, first, switch to the Git repository and check the remote list. Execute the “$ git remote rm origin” command. In contrast, you can also remove the remote origin using the configuration file. This post demonstrated the procedure for removing the remote origin from the 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.