How to Remove a Git Remote

By 

Updated on

4 min read

How to Remove a Git Remote

A Git remote is a reference that points to another copy of the repository, usually hosted on a remote server. When you git clone a repository , Git automatically creates a remote named origin that points to the cloned URL.

When collaborating on a project, you may work with multiple remotes. If a remote repository is migrated to another host or a contributor stops making contributions, you may want to remove the remote from your local repository.

This guide explains how to remove a Git remote using the git remote rm command.

If you need to create a new remote first, see our guide on adding Git remotes . If you need to update a URL, see our guide on changing a Git remote URL .

Listing Remotes

Before removing a remote, list the current remote connections with git remote -v:

Terminal
git remote -v
output
origin	https://github.com/user/repo.git (fetch)
origin	https://github.com/user/repo.git (push)
testing	git@gitserver.com:user/repo.git (fetch)
testing	git@gitserver.com:user/repo.git (push)

Removing a Remote

To remove a remote, use the git remote rm command followed by the remote name:

Terminal
git remote rm <remote-name>

For example, to remove a remote named testing:

Terminal
git remote rm testing

You can also use the long form git remote remove, which does the same thing:

Terminal
git remote remove testing

The command removes all references to the remote repository from your local configuration. It does not delete the repository on the remote server.

To verify that the remote was successfully removed, run git remote -v again:

Terminal
git remote -v
output
origin	https://github.com/user/repo.git (fetch)
origin	https://github.com/user/repo.git (push)

The testing remote is no longer listed.

What Gets Removed

When you run git remote rm, Git removes:

  • The remote entry from the .git/config file
  • All remote-tracking branches associated with that remote (e.g., testing/main, testing/dev)

This is why using git remote rm is preferred over manually editing .git/config — the command cleans up tracking references automatically.

Error: No Such Remote

If the remote you are trying to remove does not exist, Git prints an error message:

output
fatal: No such remote: 'testing'

Verify the remote name with git remote -v and try again.

Renaming a Remote

If you need to change the name of a remote rather than remove it, use the git remote rename command:

Terminal
git remote rename <old-name> <new-name>

For example, to rename testing to staging:

Terminal
git remote rename testing staging

This updates all remote-tracking branches to use the new name.

Troubleshooting

fatal: No such remote when running git remote rm
Run git remote -v to verify the exact remote name. Remote names are case-sensitive.

Local branch shows gone upstream after removing a remote
Your local branch still exists, but its upstream reference was removed with the remote. Set a new upstream with git branch --set-upstream-to=<remote>/<branch> <local-branch>, or unset it with git branch --unset-upstream <local-branch>.

Quick Reference

CommandDescription
git remote -vList all remotes
git remote rm <name>Remove a remote
git remote remove <name>Remove a remote (long form)
git remote rename <old> <new>Rename a remote

FAQ

Does removing a remote delete the repository on the server?
No. The git remote rm command only removes the local reference. The remote repository remains untouched.

What happens to tracking branches when I remove a remote?
All remote-tracking branches associated with that remote (e.g., testing/main) are deleted from your local repository. Local branches that were tracking those remote branches are not deleted but will no longer have an upstream.

Can I re-add a remote after removing it?
Yes. Use git remote add <name> <url> to add the remote again at any time.

Conclusion

Use git remote rm to remove a remote reference from your local repository. The command cleans up both the configuration entry and all associated tracking branches. If you only need to change the name, use git remote rename instead.

If you have any questions, feel free to leave a comment below.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page