Re: "git clone --shallow-exclude ...", fatal: the remote end hung up unexpectedly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 15, 2019 at 9:31 PM Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote:
>   also, i think "man git-clone" could really use a set of examples for
> shallow cloning. i'd offer to write it but i'm still figuring it out.

Cool. I'll give you a quick introduction to help with those examples :D

Side note: there's also narrow/lazy clone (or something with the
promisor) but I still haven't caught up with that. So none of that
here, but I think we should eventually have some examples/description.

A shallow clone is basically a repository with commit history cut
short. If you have a commit though, you have full content. It's not
cut by paths or anything.

"git clone --depth=X" the the normal way to do this. You get a
repository where all branches and tags have maximum X commits deep.
But since the main purpose of shallow clone is redude download,
--single-branch is made default when --depth is present, so you get
the default branch instead of all the branches (you would need
--no-single-branch for that). You could see these cut points with "git
log --decorate". I think they are marked "crafted" or something.

Once you have made a shallow clone, you could do everything like
usual. Local operations of course can only reach as far as the cut
points. Pull and push to a full clone are possible (it's even possible
to do so to another shallow clone).

When you "git fetch", the cut points remain the same, so you get more
recent commits and the history depth increases. If you do "git fetch
--depth=X" then the cut points are adjusted so that you only have
maximum X commits deep for all select branches, the same way a shallow
clone is made initially. "git fetch --unshallow" can be used to turn a
shallow clone into a complete one. And I'm pretty sure you could turn
a complete one to shallow with "git fetch --depth".

While --depth works fine most of the time, sometimes you want a
different way to define these shallow/cut points. --shallow-since and
--shallow-exclude are added as the result. --shallow-since cut the
history by a specific date (for all select branches).
--shallow-exclude cuts the history by a ref (often a tag). As I
mentioned before, it's mostly used to say "I want a shallow clone from
(but not including) v2.9.0".

And I think that's pretty much it. There's --update-shallow option but
I can't remember when that's needed. Shallow clones may also prevent
you from using some optional features. Pack bitmap is one of those and
I think probably commit graph too. It's not technical limitation, just
lack of time/effort to support them in shallow clones.
-- 
Duy



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux