Skip to content

How to fix error: remote origin already exists?

  • by
  • 3 min read

If you’re a developer, version management systems and especially GitHub are probably the best thing that ever happened to you. However, as is always the case with programming and development, nothing goes without a random error popping up out of nowhere and GitHub is no exception. 

In this article, we’re talking about the “error: remote origin already exists” problem, its causes and what you can do to fix the issue. 


What causes this issue?

The error generally gets triggered when you clone a repository onto your local machine and try to change the pointing origin URL to your own local repository. The most common cause of the error is just a misconfiguration in terms of repository settings but it’s also often caused by the cloned repository having its own URL already configured. 

Also read: How to create a Git repository? How to connect it to GitHub?


How to fix this?

Here are three fixes you can try out.

Removing the existing remote origin

As mentioned before, one of the most common causes of the error is the fact that the local ‘origin’ isn’t available. Do keep in mind that ‘origin’ in this context refers to the local name of the remote repository. Just type the following command to remove the remote repository:

git remote rm origin

You can also remove the upstream remote using this command.

git remote rm upstream

Update the existing remote URL

Conflicting remote URLs also trigger this error. You can fix this by updating the remote URL using the command below. 

git remote set-url origin [new URL]

Ensure that you’re pointing to a valid repository in the target URL otherwise, you’ll have to repeat this process except with a different error code. 

This is an image of github featured 33

Renaming the remote

If you don’t need to move the local repository around and it’s meant to stay offline, you can also try and simply rename the remote to something else so that you don’t have to worry about conflicting repositories between your local system and Github. Here’s how. 

git remote rename origin [new name]

You can, of course, use the command to rename any other repositories as well. Simply replace ‘origin’ with the name of the target repository and you’re good to go. 

Also read: How to delete a repository and branch in GitHub?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>