When you want to remove remote origin from Git, there are multiple ways to do it and reasons to. If the repository is no longer active or there have been work network changes, you may want to remove remote.
The most straightforward way of doing it is by using the remove remote command. First, you should navigate to your directory where the repository is located using the traditional cd commands. Then, use the remove command whose syntax is:
git remote rm <remote-name>
For example, your command line should look like this:
C:\Users\thomashyde\reps\random-repos-name>git remove rm riposte
This command doesn’t remove the repository directly, instead, it deletes the references to it. Also, depending on your software version, you can replace the “rm” with “remove” in the command.
git remote remove <remote-name>
If you want to double-check whether the remote remove command has worked or not, you can use this command:
For example, use git remote -v and you probably will get something similar to this output:
origin https://github.com/thomashyde/random-repos-name.git (fetch)
origin https://github.com/thomashyde/random-repos-name.git (push)
(considering you’re using https)
This command will not work in either of two cases; the remote you typed has incorrect spelling or the remote no longer exists (deleted).
Through the Config File
Every git has its own config file, .git/config. You can navigate this file as well using cd commands, access it using a text editor, and delete remote from there manually.
Changing the Origin
Many times, users only require or want to move the remote origin from one destination to another. In such cases, removing the remote becomes an unnecessary task and instead shifting the destination becomes more efficient.
git remote set-url origin newgiturl command can work. You can of course use this in your config file as well.
git remote set-url origin https://github.com/thomashyde/riposte3.git for example.
Wrapping It Up
Now that you know how to remove remote from Git and want to extend you knowledge further we recommend you to learn more about Linux commands. These will come in handy at any given time while navigation through a Linux based OS.
Best Linux Distros for Developers and Programmers as of 2022
Linux might not be the preferred operating system of most regular users, but it’s definitely the go-to choice for the majority of developers and programmers. While other operating systems can also get the job done pretty well, Linux is a more specialized OS that was…
How to Install Pip on Ubuntu Linux
If you are a fan of using Python programming language, you can make your life easier by using Python Pip. It is a package management utility that allows you to install and manage Python software packages easily. Ubuntu doesn’t come with pre-installed Pip, but here…