git remote rm removes a tracked remote reference from .git/config. Syntax: git remote rm <remote-name> (alias: git remote remove).
git remote rm <remote-name>
# or
git remote remove <remote-name>
Options and Flags
| Flag | Type | Default | Description |
|---|---|---|---|
| -v, –verbose | flag | N/A | Show verbose output when listing remotes (used before removal to verify). Not used directly with rm. |
| <remote-name> | argument | required | Name of the remote to remove (e.g., origin, upstream). Must exist in local config. |
Usage Examples
1. Remove the default remote ‘origin’
git remote rm origin
# Verify removal
git remote -v
# No output indicates success
Use this after finishing work with a remote repository or to reconfigure for a different remote. The operation is irreversible except by re-adding the remote.
2. List remotes before removal
git remote -v
# Output:
# origin git@github.com:user/repo.git (fetch)
# origin git@github.com:user/repo.git (push)
git remote rm origin
Always verify remote names with -v before removal to avoid removing the wrong remote, especially in repos with multiple remotes (e.g., origin, upstream, staging).
3. Remove a remote after renaming
git remote -v
# origin -> https://github.com/OWNER/REPOSITORY.git
git remote rename origin destination
git remote rm destination
# Config section removed
This pattern helps avoid the “remote origin already exists” error when adding a new remote. Rename before removing to preserve a reference if needed.
4. Remove a remote that doesn’t exist (error handling)
git remote rm nonexistent
# Output: fatal: No such remote 'nonexistent'
# Exit code 1
A common mistake when the remote name is misspelled or already removed. Verify with git remote -v first.
Troubleshooting & Common Errors
| Error Message/Code | Root Cause | Resolution Command |
|---|---|---|
fatal: No such remote '<name>' |
Remote name does not exist in local config. |
|
error: Could not remove config section 'remote.<name>' |
Git could not delete the section from .git/config (permissions or corruption). |
|
fatal: remote origin already exists |
Attempting to add a remote with a name already present. |
|
Closing Tip
Always run git remote -v before git remote rm to confirm the remote name. Removal is irreversible — re-adding requires the full URL.
Frequently Asked Questions
What is the difference between git remote rm and git remote remove?
Answer: None – they are exact aliases. Both are identical in Git source code. Use whichever you prefer; there is no functional difference.
git remote rm origin # removes remote named 'origin'
git remote remove origin # identical to above
When should I use git remote remove instead of git remote prune?
Answer: Use remove to permanently delete a remote. git remote remove deletes the remote URL and all remote-tracking branches. git remote prune origin removes local references to branches that no longer exist on the remote but keeps the remote itself.
git remote remove deprecated-server # removes remote entirely
git remote prune origin # cleans stale branch references only
How do I fix error “fatal: No such remote: ‘upstream'” when removing a remote?
Answer: Verify the remote name with git remote -v. This error occurs when the remote name doesn’t exist in .git/config. To confirm:
git remote -v
# if 'upstream' is listed, re-run: git remote remove upstream
# if not, the remote was already deleted – no action needed
Common causes: typo, whitespace, or removal by another process. Use cat .git/config to inspect remote entries.
Does git remote remove work on all platforms (Linux, macOS, Windows, cloud CI runners)?
Answer: Yes – it is a core Git command available in Git ≥1. It manipulates the local repo’s .git/config file, which is POSIX-compliant. Runs without modification on GitHub Actions, GitLab CI, Jenkins, and Azure Pipelines. Windows users: avoid backslashes in remote names – forward slashes are universal.
# Example: removing a remote in a CI job
git remote remove deployment-server
What is the fastest way to remove multiple remotes in Git?
Answer: Use a shell loop: for r in remote1 remote2; do git remote remove "$r"; done. To remove all remotes except a specific one:
for r in $(git remote | grep -v keep-this); do git remote remove "$r"; done
Always test with echo first.

Command Line Expert & Software Engineer
Welcome! I’m Thomas Heinrich, a software engineer and system administrator with a deep passion for the Command Line Interface (CLI). With years of experience navigating the terminal, building backend architectures, and automating server deployments, I created this space to share practical, real-world terminal knowledge.
Whether you are a beginner taking your first steps in a Linux environment or a seasoned DevOps engineer looking to optimize your deployment scripts, you will find actionable solutions here. My goal is to help you ditch the mouse, speed up your workflow, and harness the full power of the command line.