How to fix fatal: The remote you are trying to track already exists in Git

GitBEGINNERLOWUpdated Dec 6, 2025ยท 183 views

The 'fatal: remote origin already exists' error occurs when you try to add a remote repository with a name that's already configured. Fix it by updating the existing remote URL, removing and re-adding the remote, or using a different remote name.

Quick fix

Fixes fatal: The remote you are trying to track already exists

git remote -v
  1. Check existing remotes
  2. Update the existing remote URL (recommended)
  3. Remove and re-add the remote
  4. Rename the existing remote
git โ€” error
git remote -v
fatal: The remote you are trying to track already exists

What this error means

The "fatal: remote origin already exists" error in Git indicates that you're trying to add a new remote with a name that already exists in your repository's configuration. When you run `git remote add origin <url>`, Git attempts to create a new remote entry named "origin" pointing to the specified URL. However, if a remote with that name already exists (which is common since "origin" is the conventional name for the primary remote), Git refuses to overwrite it and throws this error. This commonly happens when: - You clone a repository (which automatically creates an "origin" remote) and then try to add origin again - You're setting up a local repository to push to a new GitHub/GitLab repository but forgot you already configured a remote - You're following a tutorial that assumes no remote exists yet - You're migrating between Git hosting providers and need to change the remote URL The error is Git's way of preventing accidental overwrites of your remote configuration, which could lead to pushing code to the wrong repository.

Typical symptoms

  • Running 'git remote add origin <url>' fails with 'fatal: remote origin already exists'
  • Cannot set up a new remote repository connection
  • Following repository setup instructions fails at the 'add remote' step
  • Cloned repository shows error when trying to add same remote name
  • Git operations work but you can't change where you push/pull from

Common causes

  1. A remote with the name 'origin' (or whatever name you specified) already exists in the repository
  2. You cloned the repository, which automatically created an 'origin' remote
  3. You previously added a remote and forgot about it
  4. You're following setup instructions that assume a fresh repository with no remotes
  5. The repository was forked or copied from another source that included remote configuration

How to fix "fatal: The remote you are trying to track already exists"

1Check existing remotes

First, view your currently configured remotes to understand the situation:

bash
git remote -v

This shows all remotes with their fetch and push URLs. You'll likely see something like:

bash
origin  https://github.com/olduser/oldrepo.git (fetch)
origin  https://github.com/olduser/oldrepo.git (push)

Now you know what remote already exists and can decide how to proceed.

2Update the existing remote URL (recommended)

If you want to change where the existing remote points to, use set-url:

bash
git remote set-url origin https://github.com/yourname/newrepo.git

This updates the URL for the existing "origin" remote without removing any configuration. Verify the change:

bash
git remote -v

You should now see the new URL. This is the safest and most common solution.

3Remove and re-add the remote

If you prefer to start fresh with the remote configuration:

bash
# Remove the existing remote
git remote remove origin

# Add it back with the new URL
git remote add origin https://github.com/yourname/newrepo.git

Verify the change:

bash
git remote -v

This approach is useful when you want a clean slate or if set-url doesn't work for some reason.

4Rename the existing remote

If you want to keep the original remote and add a new one, rename the existing remote first:

bash
# Rename 'origin' to something else
git remote rename origin old-origin

# Now add your new origin
git remote add origin https://github.com/yourname/newrepo.git

Verify both remotes exist:

bash
git remote -v

This is useful when migrating between providers and you want to keep a reference to the old repository.

5Use a different remote name

If you need to add a second remote without modifying the existing one, simply use a different name:

bash
# Add as 'upstream' (common for forks)
git remote add upstream https://github.com/original/repo.git

# Or use any descriptive name
git remote add github https://github.com/yourname/repo.git
git remote add gitlab https://gitlab.com/yourname/repo.git

Common remote naming conventions:
- origin: Your primary remote (usually your fork or main repo)
- upstream: The original repository you forked from
- Provider names (github, gitlab, bitbucket): When pushing to multiple platforms

6Push to the updated remote

After updating your remote configuration, push your code:

bash
# Push and set upstream tracking
git push -u origin main

If your local branch is named 'master' instead of 'main':

bash
git push -u origin master

The -u flag sets up tracking so future git push and git pull commands know which remote branch to use.

Advanced notes

### Understanding Git Remotes

A remote in Git is simply a named reference to another repository. The .git/config file stores these references:

ini
[remote "origin"]
    url = https://github.com/user/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*

You can have multiple remotes pointing to the same URL with different names, or multiple remotes pointing to different repositories.

### Working with Multiple Remotes

When working with forks, a common setup is:

bash
# Your fork
git remote add origin https://github.com/yourname/repo.git

# Original repository
git remote add upstream https://github.com/original/repo.git

This allows you to:
- Push changes to your fork: git push origin feature-branch
- Pull updates from the original: git pull upstream main

### SSH vs HTTPS URLs

Git remotes can use different protocols:

bash
# HTTPS (requires username/password or token)
git remote set-url origin https://github.com/user/repo.git

# SSH (requires SSH key setup)
git remote set-url origin git@github.com:user/repo.git

If you're switching between protocols, use set-url to update the existing remote.

### Checking Remote Configuration

To see detailed remote information:

bash
# Show remote details
git remote show origin

# Show all remotes with URLs
git remote -v

### Common Mistakes to Avoid

1. Don't use `git remote add` to change URLs - use git remote set-url instead
2. Don't delete and recreate without checking tracking branches first
3. Remember to update tracking after changing remotes with git push -u

Frequently asked questions

What does "fatal: The remote you are trying to track already exists" mean?
The "fatal: remote origin already exists" error in Git indicates that you're trying to add a new remote with a name that already exists in your repository's configuration. When you run git remote add origin <url>, Git attempts to create a new remote entry named "origin" pointing to the specified URL. However, if a remote with that name already exists (which is common since "origin" is the conventional name for the primary remote), Git refuses to overwrite it and throws this error.
How do I fix "fatal: The remote you are trying to track already exists"?
The 'fatal: remote origin already exists' error occurs when you try to add a remote repository with a name that's already configured. Fix it by updating the existing remote URL, removing and re-adding the remote, or using a different remote name.
What causes "fatal: The remote you are trying to track already exists"?
A remote with the name 'origin' (or whatever name you specified) already exists in the repository You cloned the repository, which automatically created an 'origin' remote You previously added a remote and forgot about it
Is the "fatal: The remote you are trying to track already exists" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading