How to remove git remote

Git is an open-source software with version control support that allows the users to store, edit and track the changes of projects.

There are various benefits in using Git that include: fast and efficient processing on shared projects as well as monitoring the security of the projects. However, one of the major reasons for the emergence of Git is the remote repository access; the Git remote repository is available on the server and multiple contributors can make changes to it. Users can clone the remote repository to their machines and can retrieve required information from Git repository locally or it can help to do experimental analysis on the files of the repository without affecting its originality on the server. This cloning phenomenon allows to establish the connection between git remote repository and local repository; moreover, it also supports creating several clones of a single git repository so that multiple stakeholders can get access to the same project and can-do changes parallelly. The terminal support of Ubuntu can be used to add or remove the remote repositories as your local one.

In this article, we will present the procedural guide that demonstrate how to remove the remote repository using terminal in Ubuntu:

So, let’s start this tutorial:

How to add Git remote locally in Ubuntu

First, we will have a quick look to add a new remote using git remote add command:

Create a local Git repository first by issuing the command mentioned below:

$ git init

Once the repository is created you can add the remote to your local Git repository with the help of below-mentioned command: we have added the remote and named it as “linuxhint”:

$ git remote add linuxhint

How to remove Git remote in Ubuntu

To remove the Git remote on your Ubuntu, there are two ways that can be adopted to perform this action:

  • Method 1: How to remove Git remote using command support in Ubuntu terminal
  • Method 2: How to remove Git remote using .config file

The above written both methods remove the remote, but Method 1 follows few commands to remove the remote:

Method 1:

Firstly, we have to identify the available list of remotes on your machine: you can copy and paste the command written below to get to the list:

$ git remote -v

Now after viewing the list of available remotes; you must identify the remote to be removed: For instance, in our case we are removing “linuxhint” remote from our local repository. So, the following command will help us in this regard:

$ git remote rm linuxhint

After removal of the remote, you can verify the change by again checking the available remotes using the following command:

It is observed from the output that “linuxhint” remote has been removed and nothing left in the list as there was only one remote:

$ git remove -v

Method 2: How to remove Git remote using config file of Git repository

This method can also be performed using terminal or you can edit the config file using your default text editor:

The following command will help you to get the edit access of config file using nano editor:

Note: Make sure your terminal is opened where your git project resides or where you have created the Git repository.

$ nano .git/config

Here, you will notice the remote names; as in this case there are two remotes named as “polly” and “origin”; you have to erase the config lines of the remote that you want to remove: for instance, we want to remove “polly”; so we have to remove the config of “polly” remote from the config file; the setting associated to “polly” remote is displayed in the image below; just select these lines and remove them:

After the removal, press “Ctrl+S” to save the changes in the .config file and get out of nano editor by using “Ctrl+x”:


Git, primarily developed on Linux, has extensive support for other operating systems too: since its development back in 2005, the long list of supported features of Git attracted the industrialists of the software domain to maintain their projects on Git server as well as locally. In this descriptive guide, we have provided the possible ways to remove Git remote on your Ubuntu. The Git remote can be removed from Ubuntu by using commands in the terminal or you can remove it by accessing and manipulating the config file of the Git repository.

About the author

Adnan Shabbir