All Articles

Removing a Git Remote

I was pushing a repository to two remote repositories (for example, GitHub and GitLab) for a time. I’ve now deleted one remote repository because the feature I was utilizing in that provider is now available in the other. As a result, I needed to delete one of the remotes locally.

List the Remotes

We can pass the -v (verbose) flag to list the remote branches.

git remote -v

Results in:

demo    https://example.com/namespace/repo (fetch)
demo    https://example.com/namespace/repo (push)
origin  [email protected]:namespace/repo.git (fetch)
origin  [email protected]:namespace/repo.git (push)

Deleting the Remote Branch

Now, we can use git remove rm <remote_name> to delete the remote.

git remote rm demo

Let’s check the remotes again:

$ git remote -v
origin  [email protected]:namespace/repo.git (fetch)
origin  gi[email protected]:namespace/repo.git (push)

As we can see, the remote demo has been deleted.