You are on page 1of 2

Explore your training options in 10 minutes GET STARTED X

Browse Bootcamps  Learn For Free  For Companies  About  Sign In Get Matched

RESOURCE CENTER BOOTCAMPS  CODING  TECH SKILLS  CAREER RESOURCES  HIGHER ED  ED FINANCING  ABOUT

Resource Center  Git  Git fatal: remote origin already exists Solution

Git fatal: remote origin already exists


Solution
BY JAMES GALLAGHER UPDATED 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.

Find your bootcamp match

Select Your Interest Your Experience Time To Start


Apply to top tech

Software Engineering Beginner Now GET MATCHED training programs in

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. one click

fatal: remote origin already exists GET MATCHED

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.

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.

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?

W A NT T O TA K E A C T ION?

Get matched with top bootcamps

W A NT T O DIV E DEEP ER ?

Ask a question to our community

W A NT T O EX P LOR E T EC H C A R EER S?

Take our careers quiz

About the Author

James Gallagher

Technical Content Manager at Career Karma

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 tuto... read more

COMMENTS (0) 

Deprecated: the_category_ID is deprecated since version 0.71! Use get_the_category() instead. in /var/www/blog/blog/wp-includes/functions.php

on line 5211

Related Articles

Git fatal: remote origin already exists Git Add Remote: A Beginner’s Guide

Solution

Git Fixes: The Current Branch Has No How to Fix the Remote ‘updates were

Upstream Branch rejected’ Git Error

Error: Failed To Push Some Refs To Remote Git Remove Remote: A Guide

Git: List Remote Branches Git Status: A Guide to Responses

Git fatal: ‘origin’ does not appear to be a git

repository Solution

Rankings Locations Careers

Best Coding Bootcamps San Francisco Bootcamps Software Engineering


Home
Best Online Bootcamps New York Bootcamps UX/UI Design

About Best Web Design Bootcamps Los Angeles Bootcamps Data Science

Careers Best Data Science Bootcamps Chicago Bootcamps Web Development

Best Data Analytics Bootcamps Seattle Bootcamps Mobile Development


Mission
Best Cyber Security Bootcamps Atlanta Bootcamps Cybersecurity

Resource Center
Best ISA Bootcamps 2020 Austin Bootcamps Product Management

Press See all See all See all

Sitemap
Comparisons Schools Subjects

Terms & conditions


Flatiron School vs Fullstack Academy Coding Temple JavaScript

Hack Reactor vs App Academy Flatiron School Python

Fullstack Academy vs Hack Reactor Thinkful Ruby

    Thinkful vs General Assembly General Assembly Java

Flatiron School vs Thinkful Springboard Swift

General Assembly vs Flatiron School Galvanize Android

App Academy vs Lambda School Hack Reactor .Net

© 2023 Career Karma


General Assembly vs Hack Reactor App Academy React

Springboard vs Thinkful Bloc Angular

See all See all See all

You might also like