The short: is there a way to have a git repo push to and pull from a list of remote repos (rather than a single "origin")?
The long: I often have a situation when I'm developing an app in multiple computers, with different connectivity – say a laptop while on transit, a computer "A" while I'm in a certain location, and another computer "B" while on another. Also, the laptop might have connectivity with only either "A" or "B", and sometimes both.
What I would like to is for git to always "pull" from and "push" to all the computers it can currently connect to, so it's easier to jump from one machine to the other and continue working seamlessly.
Best Answer
Doing this manually is no longer necessary, with modern versions of
git
! See Malvineous's solution, below.Reproduced here:
Original answer:
This something I’ve been using for quite a while without bad consequences and suggested by Linus Torvalds on the git mailing list.
araqnid’s solution is the proper one for bringing code into your repository… but when you, like me, have multiple equivalent authoritative upstreams (I keep some of my more critical projects cloned to both a private upstream, GitHub, and Codaset), it can be a pain to push changes to each one, every day.
Long story short,
git remote add
all of your remotes individually… and thengit config -e
and add a merged‐remote. Assuming you have this repositoryconfig
:… to create a merged‐remote for
"Paws"
and"Codaset"
, I can add the following after all of those:Once I’ve done this, when I
git push Origin Master
, it will push to bothPaws/Master
andCodaset/Master
sequentially, making life a little easier.