Fixing the ‘Fatal: Remote Origin Already Exists’ Error in Git – 7 Steps

Image about Fixing the ‘Fatal: Remote Origin Already Exists’ Error in Git – 7 Steps

If you are a Git user, chances are you have encountered the dreaded “Fatal: Remote Origin Already Exists” error at some point. This error can be frustrating and confusing, especially for beginners.

But fear not, in this article, we will break down this error message, understand its causes, and provide you with a step-by-step guide to fix it. So let’s dive in and solve remote error in Git.

What is “Fatal:Remote Origin Already Exists Error” in Git?

To understand this error, let’s first grasp the concept of a ‘remote’ in Git.

In Git, a remote is a connection or path to another repository, typically hosted on a remote server. It allows you to collaborate with others by sharing and exchanging code. So what is the error about?

The remote error stating “origin already exists” means that the origin remote you are trying to add is already there.

Breaking Down the “error: remote origin already exists” Message

Before we proceed with the solution, let’s break down the error message you see when encountering the “Fatal: Remote Origin Already Exists” error. Understanding the terminology used in the message can give us clues on how to resolve the issue effectively.

  1. Error – The presence of the word “Error” indicates that something went wrong in the Git operation. In this case, it is related to the remote origin configuration.
  2. Remote – The term “Remote” refers to the remote repository you are trying to add or configure.
  3. Origin – The word “Origin” is the default name Git assigns to the remote repository. It serves as a convenient label to refer to the remote when executing Git commands.

What Causes Git Fatal:Remote Origin Already Exists Error?

Now that we have a basic understanding of remotes, let’s explore some scenarios that could lead to the “Fatal: Remote Origin Already Exists” error. By knowing these causes, we can better troubleshoot and fix the issue.

  1. Attempting to add an existing remote – This error occurs when you try to add a remote that already exists. This can happen due to accidental duplication or when cloning a repository that already has a remote configured.
  2. Mismatched URLs for the remote repository – Using different URLs for the same remote repository can lead to this error. Git treats each URL as a separate remote, so attempting to add another URL will result in the error.
  3. Duplicated configurations or corrupted .git directory – Another situation that can trigger this error is using different URLs for the same remote repository.

How to Fix “fatal: remote origin already exists Error” in Git?

Now that we understand the causes and have dissected the error message, let’s move on to the solution. Here is a step-by-step guide to help you fix the “Fatal: Remote Origin Already Exists” error:

1. Using the ‘git remote rm’ command

The first approach to resolving this error is to use the ‘git remote rm’ command. This command allows you to remove the existing origin remote before adding the new one.

  • Open the command line or terminal.
  • Go to your project folder by typing cd path/to/your/project.
  • Type git remote rm origin and press enter.
  • This command removes the old connection named “origin”.
  • Now you can add the new connection.
  • Type git remote add origin and press enter.
  • This adds a new connection named “origin” with the new URL.

2. Removing the existing origin

First, let’s remove the existing origin remote. The steps to remove the remote URL is given below.

  • Open the place on your computer where you type in commands (terminal or command prompt).
  • Go to the folder of your project by typing cd foldername.
  • Now type git remote rm origin and hit enter.
  • This command takes away the old link named ‘origin’ from your project.

3. Adding the new or corrected origin URL

Next, let’s add the new or corrected origin URL to the origin repository.

  • Open your command line or terminal.
  • Go to your project’s folder by typing cd path/to/your/project.
  • Now type git remote add origin new_origin_url but replace ‘new_origin_url‘ with the actual new URL.
  • Press enter.
  • This command sets up a new link named “origin” with the new URL for your project.

4. Checking and Editing the .git/config file

If the first approach doesn’t resolve the error, we can manually edit the ‘.git/config’ file to correct any mismatches or duplicates. Here’s how:

  • Open your project folder.
  • Find and open the ‘.git’ folder.
  • Inside, find and open the ‘config’ file with a text editor.
  • Look for lines starting with [remote “origin”].
  • Under this section, check and correct the URL to the desired value.
  • Save and close the file.
  • Now, check the remote URL again with git remote -v to ensure the changes are reflected.

5. Navigating to your repository’s configuration

Usually after reviewing the remote origin URL the Git error is fixed. Try this method in case the error still persists.

  • Open your project in a text editor.
  • Find a folder named ‘.git’.
  • Inside ‘.git’, find and open a file named ‘config’.
  • This ‘config’ file has settings for your project, including remote connections.

6. Manually editing or removing duplicate remote entries

Removing duplicate entries with the same name in the config section can help in fixing the Git error. Follow these steps.

  • Open the ‘.git/config’ file.
  • Look for lines that start with [remote “origin”].
  • If you see duplicates, remove or change them.
  • Save and close the file.

7. Recloning the repository (as a last resort)

If nothing works to fix the error, try getting a fresh copy of your project. First, save any work you did. Delete the project from your computer. Then download it again from Git. Now you have a clean start without the error.

How to Prevent the “error: remote origin already exists” in Future?

Now that you have successfully resolved the “Fatal: Remote Origin Already Exists” error, let’s discuss some tips to prevent encountering it again in the future:

  • Always check current remotes using ‘git remote -v’ – Before making changes or adding new links in Git, it’s wise to check the existing ones with ‘git remote -v‘. This shows you all the current links, helping avoid any repeats or mix-ups.
  • Be cautious when switching between URLs (HTTPS and SSH) – If you need to change the way you connect to Git from HTTPS to SSH or vice versa, make sure to remove the old connection before setting up the new one.
  • Understand the difference between ‘add’ and ‘set-url’ commands – In Git, when dealing with connections, know that ‘git remote add‘ is for adding a new connection, while ‘git remote set-url‘ is for changing an existing one. Using the right one helps avoid setup mistakes.


In this post, we looked at a common Git error. We learned what a remote is and saw how the error happens. We also broke down the error message. We shared a step-by-step guide to fix it and tips to avoid it later.

It’s normal to see errors in Git. Knowing how to fix them is key for easy work on Git. Follow this guide to fix the “Fatal: Remote Origin Already Exists” error and keep working on your Git projects without an issue.

Git Error Remote Origin Already Exists FAQ’s

1. What does “Error: Remote Origin Already Exists” mean?

It means there’s a mix-up with the remote links in your Git project.

When does this error usually occur?

When trying to add a new remote link but one named “origin” already exists.

How can I check my current remote links?

Use the command git remote -v to see all remote links.

How do I fix this error?

Remove the old link using git remote rm origin, then add the new link.

Can I prevent this error?

Yes, always check existing remote links before adding new ones to avoid duplicates.