Skip to main content
X

Explore your training options in 10 minutes

Git fatal: remote origin already exists Solution

James Gallagher - March 29, 2021


The “origin” keyword is commonly used to describe the central source of a Git repository. If you try to add a remote called “origin” that already exists, you will encounter the “fatal: remote origin already exists” error.

In this guide, we discuss the cause of and the solution to the fatal: remote origin already exists , with reference to an example. Let’s get started.

fatal: remote origin already exists

The Git fatal: remote origin already exists error indicates you are trying to create a remote with the name “origin” when a remote with this name already exists. This error is common if you have forgotten to set up a repository and are following setup instructions again. You may also see this error if you try to change the URL of the “origin” remote repository by using the git remote add command.

Get offers and scholarships from top coding schools illustration

Find Your Bootcamp Match

  • Career Karma matches you with top tech bootcamps
  • Access exclusive scholarships and prep courses










By continuing you agree to our Terms of Service and Privacy Policy , and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.

To solve this error, you should first check if the current remote associated with the “origin” keyword has the correct URL. You can do this using the git remote -v command:

git remote -v

You will see a list formatted like this:

origin    https://github.com/career_karma_tutorials/git (fetch)
origin    https://github.com/career_karma_tutorials/git (push)

If the “origin” URL does not match the URL of your remote repository to which you want to refer, you can change the remote URL. Alternatively, you can remove the remote and set a new remote URL with the name “origin”.

An Example Scenario

We have a repository called “git” and we want to change the origin from:

https://github.com/career_karma_tutorials/git

The new origin should use the URL:

https://github.com/career_karma_tutorials/git_tutorials

To do so, we use the git remote add command, which adds a new remote to a repository:

git remote add origin https://github.com/career_karma_tutorials/git_tutorials

This command returns an error:

fatal: remote origin already exists.

Git is telling us that the “origin” remote already exists.

The Solution

We cannot add a new remote using a name that is already in use, even if we specify a new URL for the remote. In this case, we have tried to create a new remote called “origin” even though one exists. To solve the error, we must remove the existing remote called “origin” and add a new one or change the URL of the existing remote.

To remove the existing remote and add a new one, we can set a new URL for our remote:

git remote set-url origin https://github.com/career_karma_tutorials/git_tutorials

This is the preferred method because we can change the URL associated with our remote in one command. There is no need to remove the old origin and create a new one because the set-url command exists.

Venus, a software engineer at Rockbot

"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"

Venus, Software Engineer at Rockbot

Alternatively, we can remove our “origin” remote and create a new one with our new URL:

git remote rm origin
git remote add origin https://github.com/career_karma_tutorials/git_tutorials

This removes our existing “origin” remote and replaces the remote with a new one called “origin”, using the URL we have specified. But, this method uses two commands instead of the one that we used earlier.

Conclusion

The Git fatal: remote origin already exists error is caused by creating a remote called “origin” when one already exists. To fix this error, replace the URL of your existing origin using the git remote set-url command. You can also remove your existing remote called “origin” and replace it with a new one using the git remote add command.

Do you want to learn more about coding in Git? Take a look at our How to Learn Git guide . This guide is filled with learning resources to help you build upon your knowledge of Git.

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.

What's Next?

James Gallagher

About the author: James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.

Skip to main content