I have several sites that use Drupal, I have several servers, live, dev1, dev2...
Drupal's codebase repo is big (112Mb), so I'm keen to make the most of git's hard-linking abilities so that each time I add a site it's not duplicating this.
So on, say, the live server I have a bare master repo, and all my sites are clones of this, each using a different branch. This is great on the one server, hard links are used, it's fast and efficient.
But on my dev servers, they typically all clone from the bare master repo, which means two sites on the same machine can't use hard links to save space.
What I'd like to do is set up a mirror of the bare repo on each of my dev servers, and then clone from that.
dev1$ git clone --mirror live:master-bare-repo dev1-mirror-repo
dev1$ git clone -b site1 dev1-mirror-repo site1
dev1$ git clone -b site2 dev1-mirror-repo site2
All good so far. But I want the mirrors to stay in sync at all times. So I used post-receive hook on dev1's mirror to do git push --mirror origin
. Now if site1 on dev1 pushes commits, they are magically pushed to the master-bare-repo.
But what if I make a change on the live server, and push that? I can't set up a post-receive
hook to push to the other(s) because that would presumably trigger their post-receive
hooks which would end up in recursion?
Is there some clever way around this?