Can a project have two (or more) "origins" in Git?
I would like to push a single project to both github and a Heroku server.
Specifically, this error appears when adding the github repository:
$ git remote add origin https://github.com/Company_Name/repository_name.git
fatal: remote origin already exists.
Here's a sample project with multiple remotes, GitHub & GitLab:
Add remote repo for GitHub
Add remote repo for GitLab
Now you have multiple remotes in the project. Double check with
git remote -v
How do you push to multiple repositories?
You can have as many remotes as you want, but you can only have one remote named "origin". The remote called "origin" is not special in any way, except that it is the default remote created by Git when you clone an existing repository. You can configure a second remote, push to/pull from that remote, and setup some branches to track branches from that remote instead of origin.
Try adding a remote called "github" instead:
As a side note for anyone stumbling upon this question later, it is possible to have origin push to more than one git repository server at a time.
You can achieve this by using the following command to add another URL to the origin remote.