Blog Post
How to Remove Remote Origin from Git
Commands

How to Remove Remote Origin from Git

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.

Remove command

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:

git remote

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.

Related posts

Leave a Reply

Required fields are marked *

Copyright © 2020 Blackdown.org. All rights reserved.