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 2020
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 IntelliJ IDEA on Ubuntu
If you are looking for a convenient way to manage Java applications on Ubuntu, the solution may lie in the IntelliJ IDEA development platform. An excellent advantage of this option is that it is relatively suitable for beginners, but experienced users will also find it…