Riya Kapuria
Riya Kapuria

Reputation: 9800

How to handle Git error "remote origin already exists"?

I'm have two git accounts. When I am trying to register a second remote

git remote add origin [email protected]:RiyaKapuria/testing.git 
git push -u origin master

During pushing to my repo I'm getting this error:

fatal: remote origin already exists

Upvotes: 7

Views: 14440

Answers (3)

ravi sagar
ravi sagar

Reputation: 1

**We have two option:-

  1. Replace existing origin because of remote origin already exists or
  2. Set multiple origin without remove exists origin**

1.Replace existing origin: (i)Check default origin:

git remote -v

(ii)Remove default origin:

git remote remove origin

or

git remote rm origin

(iii) Now add your git URL:

git remote add origin your_git_url

  1. Set multiple origin remote:

(i) add first origin: - git remote set-url --add --push origin git://original/repo.git

(ii) Now add second origin:- git remote set-url --add --push origin git://another/repo.git same you can add more origin

Or you can solve error by help of link: https://www.youtube.com/watch?v=dnU4CPhuQRo

Upvotes: -1

Pratheesh M
Pratheesh M

Reputation: 1078

replace origin by another name. because origin already exists. Like

git remote add upstream [email protected]:RiyaKapuria/testing.git

Upvotes: 10

Mureinik
Mureinik

Reputation: 312219

You already have a remote named origin (the one you cloned from). Just give the new remote a different name and you should be OK:

$ git remote add another_origin [email protected]:RiyaKapuria/testing.git 

and then push to the another_origin by executing

git push -u another_origin master

Upvotes: 6

Related Questions