I'd like to maintain a shallow, mirrored, bare clone of several branches. I will clone locally from that for different project branches. e.g.
+------------------------------------------------------------------+
| repo1: server1:original-repo.git branches: A, B, C, D, E |
+------------------------------------------------------------------+
↓
+------------------------------------------------------------------+
| repo2: server2:shallow-bare-selective-clone branches: A, B only |
+------------------------------------------------------------------+
↓ ↓
+-------------------------------+ +--------------------------------+
| repo3: server2:clone repo2, A | | repo4: server2:clone repo2, B |
+-------------------------------+ +--------------------------------+
So I can make repo2 like this
git clone --bare --mirror --depth 1 server1:repo1 repo2
cd repo2
git fetch --depth 200 origin A
git fetch --depth 200 origin B
And then I think repo3 and 4 are really easy - they can clone all they want from repo2, they will be limited by the shallowness of repo2.
But keeping repo2 up to date from repo1 while maintaining its shallowness is what I'm stuck on (ideally I'd like to maintain everything since a certain commit, but I understand that's not possible). It seems I have to do the multiple git fetch commands each time, is this right? Is there a way to pop that in the config file so that I can just do git fetch
and it knows what I mean?