How to fix « Fatal : Remote Origin Already Exists” After cloning a repository

Mariem SOUSSI
2 min readMar 22, 2024

--

Cloning a GitHub project is a common task aimed at obtaining a local copy of the project repository, which facilitates testing, updating, and improving the project. Changes can be pushed either to the main project or to another repository as needed. However, if we intend to push to another repository, we may encounter the issue “Fatal: Remote origin already exists”. In this short article, I will explain the reason behind this issue and give you how to resolve it.

Why does this issue occur?

The command used to clone a github project is:

git clone GITHUP-REPO-URL

When we clone a GitHub project, it is already linked to the remote repository from which it is cloned. So, the origin is configured to the cloned repository URL by default. “Origin” is the default name assigned to the remote repository, but it can be customized to have another name. You can verify your linked remote repository by running the following command :

git remote -v

If you want to push your updates to a new repository, you have to define your remote repository using the command:

git remote add origin URL-OF-NEW-REPO

This command may encounter the error “Fatal: Remote origin already exists” because you already have “origin” defined, similar to attempting to create a folder with the same name in the same directory.

How to solve this issue?

To resolve this issue, you can choose one of the following two options:

Option1

  1. Delete the referenced origin using this command:
git remote rm origin

2. You can re-run this command to ensure it is removed

git remote -v

3. Recreate origin with the new repo URL using this command:

git remote add origin URL-OF-NEW-REPO

Option2

2. Update the link referenced to origin with the URL of the new repository using this command:

git remote set-url origin URL-OF-NEW-REPO

Hope you find this information helpful 😊!

--

--