Message ID | 20200421131223.29337-4-shouryashukla.oo@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | gitfaq: add issues in the 'Common Issues' section | expand |
Shourya Shukla <shouryashukla.oo@gmail.com> writes: > Add issue in 'Common issue' section which covers issues with cloning > large repositories. Use shallow cloning to clone the repository in > a smaller size. > > Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com> > --- > Documentation/gitfaq.txt | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt > index 13d37f96af..cea293cf07 100644 > --- a/Documentation/gitfaq.txt > +++ b/Documentation/gitfaq.txt > @@ -275,6 +275,20 @@ I want to change the remote of my repository. How do I do that?:: > One can list the remotes of a repository using `git remote -v` command. > The default name of a remote is 'origin'. > > +[[shallow-cloning]] > +The repository I am trying to clone is too big. Is there an alternative > +way of cloning it in lesser space?:: > + One can clone a repository having a truncated history, meaning the > + history will span upto a specified number of commits instead of > + the whole history of the repository. This is called 'Shallow Cloning'. > ... The question is worth keeping but the answer is questionable. I have a feeling that --depth/shallow is deprecated/frowned upon these days and more people recommend partial/blob-less clones instead (a few random people added to Cc: to see if they want to say something here).
On April 21, 2020 4:01 PM, Junio C Hamano > Subject: Re: [PATCH v3 3/4] gitfaq: shallow cloning a repository > > Shourya Shukla <shouryashukla.oo@gmail.com> writes: > > > Add issue in 'Common issue' section which covers issues with cloning > > large repositories. Use shallow cloning to clone the repository in a > > smaller size. > > > > Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com> > > --- > > Documentation/gitfaq.txt | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > > diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt index > > 13d37f96af..cea293cf07 100644 > > --- a/Documentation/gitfaq.txt > > +++ b/Documentation/gitfaq.txt > > @@ -275,6 +275,20 @@ I want to change the remote of my repository. > How do I do that?:: > > One can list the remotes of a repository using `git remote -v` command. > > The default name of a remote is 'origin'. > > > > +[[shallow-cloning]] > > +The repository I am trying to clone is too big. Is there an > > +alternative way of cloning it in lesser space?:: > > + One can clone a repository having a truncated history, meaning the > > + history will span upto a specified number of commits instead of > > + the whole history of the repository. This is called 'Shallow Cloning'. > > ... > > The question is worth keeping but the answer is questionable. > > I have a feeling that --depth/shallow is deprecated/frowned upon these days > and more people recommend partial/blob-less clones instead (a few random > people added to Cc: to see if they want to say something here). I rather hate to chime in as a dissenting opinion, but the --depth/shallow clone is very useful when git is being used as an artifact repository for production. The shallow clone allows only the production branch HEAD to be cloned into production/staging areas and limits the visible history for staff who do not want to go through a potentially long trail during time-sensitive operations (a.k.a. production installs). There are also space and policy constraints in some of these environments where they do not want to have ongoing visibility to non-production commit paths. When the *stuff* hits the fan, then it's good to be able to fetch everything (or a limited set). I would be very disappointed to see --depth frowned upon. Regards, Randall -- Brief whoami: NonStop developer since approximately 211288444200000000 UNIX developer since approximately 421664400 -- In my real life, I talk too much.
"Randall S. Becker" <rsbecker@nexbridge.com> writes: >> I have a feeling that --depth/shallow is deprecated/frowned upon these > days >> and more people recommend partial/blob-less clones instead (a few random >> people added to Cc: to see if they want to say something here). > > I rather hate to chime in as a dissenting opinion,... Oh, don't hate anything. It is greatly appreciated so that we can cover "in such and such use case, this solution is good" variants for similarly-sounding-but-fundamentally-different classes of problems. We do not want to give a spinal-reflex answer of "use shallow" (or "use partial", for that matter) to "too large a repo" question without contexts that guide the readers to a better choice. That is where a well-organized FAQ list shines. Thanks.
On April 21, 2020 4:58 PM, Junio C Hamano wrote: > Subject: Re: [PATCH v3 3/4] gitfaq: shallow cloning a repository > "Randall S. Becker" <rsbecker@nexbridge.com> writes: > > >> I have a feeling that --depth/shallow is deprecated/frowned upon > >> these > > days > >> and more people recommend partial/blob-less clones instead (a few > >> random people added to Cc: to see if they want to say something here). > > > > I rather hate to chime in as a dissenting opinion,... > > Oh, don't hate anything. It is greatly appreciated so that we can cover "in > such and such use case, this solution is good" variants for similarly-sounding- > but-fundamentally-different classes of problems. We do not want to give a > spinal-reflex answer of "use shallow" (or "use partial", for that matter) to > "too large a repo" > question without contexts that guide the readers to a better choice. > > That is where a well-organized FAQ list shines. I have spoken on this topic and can probably share some of it.
On Tue, Apr 21, 2020 at 1:00 PM Junio C Hamano <gitster@pobox.com> wrote: > > Shourya Shukla <shouryashukla.oo@gmail.com> writes: > > > Add issue in 'Common issue' section which covers issues with cloning > > large repositories. Use shallow cloning to clone the repository in > > a smaller size. > > > > Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com> > > --- > > Documentation/gitfaq.txt | 14 ++++++++++++++ > > 1 file changed, 14 insertions(+) > > > > diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt > > index 13d37f96af..cea293cf07 100644 > > --- a/Documentation/gitfaq.txt > > +++ b/Documentation/gitfaq.txt > > @@ -275,6 +275,20 @@ I want to change the remote of my repository. How do I do that?:: > > One can list the remotes of a repository using `git remote -v` command. > > The default name of a remote is 'origin'. > > > > +[[shallow-cloning]] > > +The repository I am trying to clone is too big. Is there an alternative > > +way of cloning it in lesser space?:: > > + One can clone a repository having a truncated history, meaning the > > + history will span upto a specified number of commits instead of > > + the whole history of the repository. This is called 'Shallow Cloning'. > > ... > > The question is worth keeping but the answer is questionable. > > I have a feeling that --depth/shallow is deprecated/frowned upon > these days and more people recommend partial/blob-less clones > instead (a few random people added to Cc: to see if they want to say > something here). I don't have a problem with us saying we have to support shallow clones for years or decades more, but I personally strongly dislike advertising it, for multiple reasons: * From an internal perspective: The shallow clone implementation feels like a hack that isn't extensible and doesn't work with other features, and as far as I can tell that's intrinsic to its design. * From an end-user perspective: Shallow clones are heavily misused, oversold, and induce or perpetuate various misunderstandings. CI systems seem especially keen on turning on shallow clones whether requested or not and breaking all sorts of things from simple (like 'git describe') to the more complex (like merge this branch with master and run tests there too to avoid breaks due to semantic conflicts) and all sorts of things inbetween (e.g. when trying to 'debug with SSH' the user can't look around in the repo because it's all missing). Despite the huge waste of time projects induce by defaulting this on and sometimes making it hard to turn off, is to 'save space' and they often sell it as a dramatic savings. B if it's a standard source code repository then usually you save only about 50% of the overall download size. (Years ago, I used to like to point out that a git clone of a repo would only be marginally bigger than a svn checkout, despite having 'all history', and had a handful of repos where I had measured the cost to back it up). The way CI folks talk about shallow clone makes people assume that 'all history' is hundreds/thousands of times bigger than the most recent checkout. The only case where 'saving size' seems to matter is either the special simple cases that have really simple builds (though they tend to be small enough that the size doesn't matter anyway) or for repos that have accidentally committed huge files in their history that are no longer present in new versions. But because shallow clones are touted so much, people come to perceive the cost of 'all history' as being a very onerous requirement in git. And the perception seems to be sticking in lots of places. I can sometimes go dig out facts for a repository in question to show people the differences in sizes and dispel some of this, but that's a one-by-one case. I think these misunderstandings hurt us as a community. * Diversion of resources: Even though there are current valid usecases for shallow clones (e.g. Randall sounds like he has some), advertising this feature is going to make it harder for us to focus efforts on the better designed solutions we want to implement and extend. Perhaps a funny story is in order: At $FORMER_JOB, we made software used by various groups on supercomputers (or high performance computers, or however you want to refer to that class of many machines). One customer requested support on Itanium machines, and we made the necessary (though painful) adjustments. At some point we decide to list our supported platforms on the DVDs we sent out. Then at some point, the Navy decides they're going to buy some nice supercomputer(s). They want to use our software, but also want to use general well-supported industry standard hardware. They put out a purchase order for $100 million (I don't remember the real number but it was large), and overlooked specifying the computer architecture. Vendors who were just about to retire the very last Itanium chips and were literally going to just scrap the rest of their inventory notice this purchase order, bid on the procurement at dirt cheap prices, and then the Navy is stuck because of "don't waste taxpayer dollars" and "procurement has to be fair". They need those machines to work for several years. Anyone who provides them software has to support that architecture for several more years, but the vendors would not sell any more Itanium machines after that even if you begged, so we were working with some really old Itanium machines that didn't have enough power to run the basic regression test in under 24 hours. The last sysadmin at $FORMER_JOB with the necessary qualifications to actually maintain those systems (not just knowledge but red tape box checking too; this was government after all) was retiring about a year and a half before the mandatory support period ended for us as well. We found out at some point that they checked our requirements before putting out the purchase order; had our DVDs only advertised support for x86_64, the whole debacle could have been avoided. Yes we totally need to support shallow clones (I brought them up as a concern for fetch.writeCommitGraphs just last week after all), but I really don't want to advertise them, and if we need to in some way, then minimize it. Anyway, that's my $0.02. Elijah
On 4/21/2020 4:43 PM, Randall S. Becker wrote: > On April 21, 2020 4:01 PM, Junio C Hamano >> Subject: Re: [PATCH v3 3/4] gitfaq: shallow cloning a repository >> >> Shourya Shukla <shouryashukla.oo@gmail.com> writes: >> >>> Add issue in 'Common issue' section which covers issues with cloning >>> large repositories. Use shallow cloning to clone the repository in a >>> smaller size. >>> >>> Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com> >>> --- >>> Documentation/gitfaq.txt | 14 ++++++++++++++ >>> 1 file changed, 14 insertions(+) >>> >>> diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt index >>> 13d37f96af..cea293cf07 100644 >>> --- a/Documentation/gitfaq.txt >>> +++ b/Documentation/gitfaq.txt >>> @@ -275,6 +275,20 @@ I want to change the remote of my repository. >> How do I do that?:: >>> One can list the remotes of a repository using `git remote -v` command. >>> The default name of a remote is 'origin'. >>> >>> +[[shallow-cloning]] >>> +The repository I am trying to clone is too big. Is there an >>> +alternative way of cloning it in lesser space?:: >>> + One can clone a repository having a truncated history, meaning the >>> + history will span upto a specified number of commits instead of >>> + the whole history of the repository. This is called 'Shallow > Cloning'. >>> ... >> >> The question is worth keeping but the answer is questionable. >> >> I have a feeling that --depth/shallow is deprecated/frowned upon these > days >> and more people recommend partial/blob-less clones instead (a few random >> people added to Cc: to see if they want to say something here). > > I rather hate to chime in as a dissenting opinion, but the --depth/shallow > clone is very useful when git is being used as an artifact repository for > production. It is important, then, to mention what the _real_ uses for shallow clones. They are great for getting just the working directory at tip for a throwaway action (like building an artifact, or just taking a static copy of something) but it is a _terrible_ way to start working on source code for a project that you intend to use for daily work. The way this is worded in the FAQ will lead users to have a bad experience and we should recommend partial clone (--filter=blob:none) instead. Of course, with the speedups from reachability bitmaps, it is sometimes _faster_ to do a partial clone than a shallow clone. (It definitely takes less time in the "counting objects" phase, and the cost of downloading all commits and trees might be small enough on top of the necessary blob data to keep the total cost under a shallow clone. Your mileage may vary.) Because the cost of a partial clone is "comparable" to shallow clone, I would almost recommend partial clone over shallow clones 95% of the time, even in scenarios like automated builds on cloud-hosted VMs. Thanks, -Stolee
Derrick Stolee wrote: > Of course, with the speedups from reachability bitmaps, it is sometimes > _faster_ to do a partial clone than a shallow clone. (It definitely takes > less time in the "counting objects" phase, and the cost of downloading > all commits and trees might be small enough on top of the necessary blob > data to keep the total cost under a shallow clone. Your mileage may vary.) > Because the cost of a partial clone is "comparable" to shallow clone, I > would almost recommend partial clone over shallow clones 95% of the time, > even in scenarios like automated builds on cloud-hosted VMs. By the way, an idea for the interested (#leftoverbits?): It would be possible to emulate the shallow clone experience making use of the partial clone protocol. That is, fetch a full history without blobs but record the "shallows" somewhere and make user-facing traversals like "git log" stop there (similar to the effect "git replace" has on user-facing traversals). Then later fetches would be able to take advantage of the full commit history, but scripts and muscle memory (e.g., the assumption that most commands will never contact the remote) that assume a shallow clone would continue to work. Would that be useful or interesting to people? Thanks, Jonathan
diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt index 13d37f96af..cea293cf07 100644 --- a/Documentation/gitfaq.txt +++ b/Documentation/gitfaq.txt @@ -275,6 +275,20 @@ I want to change the remote of my repository. How do I do that?:: One can list the remotes of a repository using `git remote -v` command. The default name of a remote is 'origin'. +[[shallow-cloning]] +The repository I am trying to clone is too big. Is there an alternative +way of cloning it in lesser space?:: + One can clone a repository having a truncated history, meaning the + history will span upto a specified number of commits instead of + the whole history of the repository. This is called 'Shallow Cloning'. + This helps to decrease the space taken up by the repository. + Shallow cloning can be done by using the `--depth` option + while cloning. Therefore, the command would look like: + `git clone --depth <n> <url>`. + Here, 'n' is the depth of the clone. For e.g., a depth of 1 + would mean fetching only the top level commits of the repository + See linkgit:git-clone[1]. + Hooks -----
Add issue in 'Common issue' section which covers issues with cloning large repositories. Use shallow cloning to clone the repository in a smaller size. Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com> --- Documentation/gitfaq.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+)