6

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

git remote add origin git@github.com:RiyaKapuria/testing.git 
git push -u origin master

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

fatal: remote origin already exists

saw303
  • 8,051
  • 7
  • 50
  • 90
Riya Kapuria
  • 9,170
  • 7
  • 18
  • 32
  • 3
    Possible duplicate of [Github "fatal: remote origin already exists"](https://stackoverflow.com/questions/10904339/github-fatal-remote-origin-already-exists) – Sudipta Mondal Oct 23 '17 at 06:33
  • Can you please execute `git remote -v` in your local Git repo and share the output with us? – saw303 Oct 23 '17 at 06:36
  • riya@RFL113:~/Desktop/test$ git remote -v another_origin git@github.com:RiyaKapuria/testing.git (fetch) another_origin git@github.com:RiyaKapuria/testing.git (push) origin git@github.com:RiyaKapuria/testing.git (fetch) origin git@github.com:RiyaKapuria/testing.git (push) – Riya Kapuria Oct 23 '17 at 06:49

2 Answers2

10

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

git remote add upstream git@github.com:RiyaKapuria/testing.git
Pratheesh M
  • 1,028
  • 6
  • 13
6

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 git@github.com:RiyaKapuria/testing.git 

and then push to the another_origin by executing

git push -u another_origin master
saw303
  • 8,051
  • 7
  • 50
  • 90
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Now i'm getting this error $: git remote add another_origin git@github.com:RiyaKapuria/testing.git $: command not found – Riya Kapuria Oct 23 '17 at 06:34
  • @RiyaKapuria I use`$` in the common way to indicate a shell prompt. It's not part of the command – Mureinik Oct 23 '17 at 06:35
  • $ git push -u another_origin masterERROR: Permission to RiyaKapuria/testing.git denied to railsfactory-riya. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. – Riya Kapuria Oct 23 '17 at 06:40