knocte
knocte

Reputation: 17939

git push *to* a shallow clone, why not?

So everybody seems to be asking why one cannot push from a shallow clone (while I actually already achieved this). However what I'm interested in is pushing to a shallow server.

This doesn't work (I've served the git repo via "git clone --bare --depth 1 the_original_repo" in my server, and I cannot clone from it because it says it is a shallow clone). But I'm thinking that if one tries to clone with the same depth as the shallow clone was created, why would we have the limitation?

My end-goal would be something like this setup:

          (shallow-SERVER)
           /            \
(full-history-client)  (shallow-client)

This way, both shallow nodes would have no history at all, but there would be a client which has the full history. If the shallow-client pushed to the shallow-server, it would mean that their depth increases, but ideally it would decrease again when the full-history-client pulls from the server.

I guess this is not doable with git nowadays, right?

Upvotes: 2

Views: 627

Answers (1)

jthill
jthill

Reputation: 60295

There's no reason you can't push from or fetch into a partial repository so long as you've got enough to generate the necessary pack, I've done both too.

But you can't set a partial repository up to serve other people.

Truly partial repos are very special-purpose, for most uses you want the path to a(t least one) local shared objects directory containing a full history in.git/objects/info/alternates instead. It's not necessary for those to even be in a repo at all. I wouldn't call that a kludge, it makes accidental gc flat-out impossible, but there may be other schools of thought on that.

Any place that can't afford even one full pack has no business serving as any kind of shared repo,

Upvotes: 3

Related Questions