Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have two remote origins for Git?

Tags:

git

Our git server will be local, but we want an server where our local repo is also kept online but only used in a push to fashion.

How can one do that?

like image 776
Ravi Chhabra Avatar asked Sep 04 '08 20:09

Ravi Chhabra


People also ask

Can I have two remote origin git?

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.

Can I have multiple git repositories?

With Git, using multiple repositories is the only way to work efficiently. This enables each team to work independently, and do their work faster. You can also make sure that developers only have access to the repositories they need access to (thus making Git more secure.)

How do I push a remote to another origin?

In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.


1 Answers

You can add remotes with git remote add <name> <url>

You can then push to a remote with git push <name> master:master to push your local master branch to the remote master branch.

When you create a repo with git clone the remote is named origin but you can create a public repository for your online server and push to it with git push public master:master

like image 188
Grégoire Cachet Avatar answered Oct 09 '22 10:10

Grégoire Cachet