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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/1-4.jpg" data-lazy- height="58" src="data:image/svg xml,” width=”709″>

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 https://github.com/marcusanth/Bat-inspired-test-case-prioritization.git

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/2-4.jpg" data-lazy- height="59" src="data:image/svg xml,” width=”724″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/3-4.jpg" data-lazy- height="112" src="data:image/svg xml,” width=”726″>

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

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/4-4.jpg" data-lazy- height="43" src="data:image/svg xml,” width=”710″>

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:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/5-4.jpg" data-lazy- height="41" src="data:image/svg xml,” width=”634″>

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.

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”:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/6-4.jpg" data-lazy- height="372" src="data:image/svg xml,” width=”733″>

Conclusion

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.