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.
We can pass the
-v (verbose) flag to list the remote branches.
git remote -v
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)
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.