0

I want to set my local repository to push to a new origin. This is what I've tried:

~ git remote add origin https://my/git/origin.git
> fatal: remote origin already exists.

For your information:

~ git remote -v
> origin    https://my/git/origin.git (fetch)
> origin    https://my/git/origin.git (push)
Pierre Prinetti
  • 9,092
  • 6
  • 33
  • 49
mangulom
  • 103
  • 1
  • 4
  • 13
  • what does output of `git remote -v` look like? – behzad.nouri Jun 12 '15 at 11:22
  • 3
    You've used the phrase "it doesn't work" a few times (in your title, in your question, and in a comment to the answer below). In general, this isn't helpful. Please make sure to include the *exact error messages* that you receive. We won't be able to help without them. – ChrisGPT was on strike Jun 12 '15 at 11:51
  • possible duplicate of [Remote origin already exists on git push to new repository](http://stackoverflow.com/questions/1221840/remote-origin-already-exists-on-git-push-to-new-repository) – Joe Jun 12 '15 at 12:20
  • http://stackoverflow.com/questions/2432764/change-the-uri-url-for-a-remote-git-repository – Nick Volynkin Jun 14 '15 at 21:30

1 Answers1

0

Git servers for your project are saved as "remotes". The default remote is usually called origin. You can have more than one, but all your remotes must have unique names.

The error you get is telling you that you already have a remote called origin configured. To know what remotes are configured for your local project, type git remote (or git remote -v for a more detailed view).

To remove your default remote, type

git remote rm origin

Then you will be able to add a new remote just as you were trying to, with

git remote add origin https://my/git/origin.git

However, I advice adding a new remote with a different name and then setting it as the default upstream. This way you could always come back and then, for example, git rebase origin master to keep your repo in sync with the original source.

git remote add mynewremote
git push -u mynewremote master
Community
  • 1
  • 1
Pierre Prinetti
  • 9,092
  • 6
  • 33
  • 49