. Advertisement .
. Advertisement .
If you want to put a remote away from your local repository, it would be best to use the git remote remove command. Sometimes, removing it accidentally requires you to add it back. That can be solved with the git remote add command.
This article will focus on the former removing practice. Let’s see which method can be used to remove a Git remove URL.
What Is A Git Remote?
Git remote reference is used to head to a Git repository’s remote version. Specifically, Git is a distributed version of the control system, allowing you to download a copy and make any change on your local device.
These changes make no impact on the repository’s main copy or the remote copy. You also have one remote Git named origin. That’s why when you start a repository, there is always a notification asking you to set up a new remote with the name of origin.
You can change the name, but the default value will remain the same. Sometimes, changing your remote is necessary and that’s where you need the git remote remove command.
How To Remove A Git Remote URL
Sometimes, when you need to move the remote repository to another host, the remote URL should be removed from your local repository.
There are two main methods to accomplish this task:
Method 1: Use The git remote rm Command
First of all, you need to view all remotes of your local repository with the git remove -v command. In this example, there are origin and upstream remotes.
Now, removing a remote cannot be easier with the git remote rm code. All you have to do is type the command with the remote name and see it removed from the list.
The function also enables you to remove a remote by editing the .git/config file manually. However, we don’t recommend you to follow this method.
If you remove an unpresent remote, there will be a fatal: No such remote: ‘<remote- name>’ error arising.
git remote -v git remote rm upstream git remote -v
Method 2: Use The git remote remove Command
The git remote remove command works the same way as the git remote rm one. In this case, you need to use it with the remote name you want to get rid of.
git remote remove upstream
Remove Remote Origin In Git
Execute the command as follows to move to your repository directory:
git remote remove [name of the remote]
Here, in the name field, type the remote name you want to delete. After running the command, the chosen reference remote will disappear from the remote repository.
This practice doesn’t delete or affect the repository. Instead, its local copy will not be associated with this remote.
The above article has discussed two common ways to remove a git remote URL with detailed examples. The git remove remote command lets users remove a pointer. So depending on your case, you should choose a suitable approach.