Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How can I do a `git push` simultaneously to 2 different remotes?

My question would be best answered by a discussion of the different approaches to maintaining a pair of remote repositories in tandem up to a certain point, after which 'normal divergence' will be assumed. Up until that point, I'd like to push to both Lakers and Celtics from a single authoritative source.

Is there one simple syntax that would make this easier at each commit, or does it deserve its own procedure file of some sort? Would this be an application for a hook, and if so, how would I construct and manage it (level of detail is up to you, I'm just looking for clues).

I'd like to entertain the notion of changes when each of the remotes make authentication changes that may affect me, say, because my account changes and they've accidentally generated a different key with the intention of informing me by email, but put the account changes in the first message and defer the key-change message until after I've already pushed. In simpler terms, how does the fact that remotes are administrated by others complicate my plan to keep initial development identical?

I don't wish to create too much of a distraction, so each of you can contribute to whichever portion of my question you feel will not take too much of your time.

like image 745
ernie.cordell Avatar asked Mar 23 '23 18:03


1 Answers

As explained in the answer "pull/push from multiple remote locations", you can set up multiple url settings for a remote:

[remote "origin"]
    url = [email protected]:Lakers/Lakers.git
    url = [email protected]:Celtics/Celtics.git

You can set this up in the git config file using git config --local --edit

Then you can do

git push origin master

To push to both repositories.

like image 126
Klas Mellbourn Avatar answered Mar 26 '23 16:03

Klas Mellbourn