4

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.

  • Do you really need to push to both repos at the same time from your machine, or this is something more like a mirror setup? BTW, u can't push to both Lakers and Celtics at the same time, it's harcoded on the git source code. It would do a rm -rf / on your system. Just for the lulz! – Juan Guerrero Jun 20 '13 at 21:20
  • That rm -rf / never gets old, does it? ;) – ernie.cordell Jun 20 '13 at 22:06

2 Answers2

6

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

[remote "origin"]
    url = git@github.com:Lakers/Lakers.git
    url = git@github.com: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.

Community
  • 1
  • 1
Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158
  • Sorry I missed the other topic: Maybe the pull on the front blinded me. This really means I've done this to myself in the way I've set up the config file. – ernie.cordell Jun 20 '13 at 22:00
  • @ernie.cordell The most effective way of thanking me is by marking my answer as accepted ;) – Klas Mellbourn Jun 20 '13 at 22:11
  • Okay, done. I do believe that this is my first question. I usually like to figure things out by myself, but this was beginning to eat at me and I hadn't any more time to spend on it. – ernie.cordell Jun 20 '13 at 22:17
1

I don't think git push provides syntax to push to two different remotes at the same time. However, writing a bash script to do this is fairly trivial. I think you could also write a hook on one remote (assuming that you have access) which pushes automatically to another remote. I haven't played with hooks yet, so I don't know the details abotu how to do that.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
  • Thanks -- a "relay" would be pretty smart. I'd have to think about it, but it might not hurt after certain external mods. While I have control of most of it, it seems like a good thought (as is much of this, but I can config solely for me), but the thought of sorting out merge/rebase problems on a "relay" seems scary. But you've answered the question I asked, which is about what to do now. – ernie.cordell Jun 20 '13 at 22:06