N Kaushik

Git fatal remote origin already exists

February 07, 2021

fatal: remote origin already exists

fatal: remote origin already exists error occurs if you are trying to add origin in a git repository and it is already exists. As the error says remote origin already exists, you might want to check if the remote origin is correct or not and change it if required.

Git provides a couple of useful commands that can be used to update the origin or change the origin.

Check the current origin:

Use the below command to check the current origin:

git remote -v

It will show you the current remote origin that is configured.

Delete the current origin:

You can remove or delete the current origin by using the below command:

git remote remove origin

After removing the origin, you can use the below command to add a new origin:

git remote add origin your_origin

Replace your_origin with your git remote.

Update origin:

Use the below command to update the origin:

git remote set-url origin your_new_origin

Just replace the origin you want with your_new_origin

Add a new remote without changing the origin:

You can also add a new remote without modifying the origin. Suppose, the new remote is origin-new, then you need to use the below command for that:

git remote add origin-new your_origin

Now, you need to replace origin with origin-new in your git commands. For example, git push origin master will be git push origin-new master

Subscribe to my Newsletter