Fix git fatal: remote origin already exists error on push

This article explains how to fix git title: ‘How to fix git fatal: remote origin already exists’ during the push or add commands.

To make any application or folder/directory as git enabled, you have to initialize the git init command.

Once git is initialized, we have to either create a new repository or existing repository to map this to existing directory.

if this directory is created in nested folder of any git repository, git command throws git fatal: remote origin already exists error.

fatal: remote origin already exists git error

What does it origin mean?

This error comes during multiple use cases

  • created a local nested folder app which is a child folder a local git repository, which this folder want to map to new remote repository
B:\blog\jswork>git remote add origin
fatal: remote origin already exists.
fatal: remote origin already exists.

This does means you are creating origin local name in already adding existing repository.

In any local repository, How do you know the remote repository url? using the -v option gives the local name with remote url as described following

git remote -v 

And the output is

origin (fetch)
origin (push)

This will gives the remote repository url mapped with local name ie origin.

origin is the local name for remote repository given by default.

This error occurs during adding new url to the existing origin.

This post covers the solution for following errors in git command

  • fatal: No such remote:
  • Remote origin already exists on ‘git push’ to a new repository


There are many ways we can fix this.

Remove origin name from the given existing repository

First, delete the local name origin for given remote repository using following command

git remote rm origin

next, add the origin name to new remote repository

git remote add origin remote-repo-url

set-url Change origin name from the given existing repository

git remote set-url neworigin remote-repo-url

if remote-repo-url does not exists, it gives an error fatal: No such remote:

Replace current origin to new url

below set the new url for local name origin.

git remote set-url origin remote-repo-url

rename existing origin name

Last approach is to rename existing origin to new name

git remote rename origin neworigin

Finally, It is important to verify the name mapped to the urls using below command

git remote -v


There are many ways we can fix this errors with above solutions

Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.