4

I looked at How do I clone a subdirectory only of a Git repository?, and the top voted answer says to use sparse checkout. But this comment says that it still downloads the entire repo.

Which is correct?

Does sparse checkout affect fetch, or does it just affect checkout?

In other words, if I have a 10GB Git repo (compressed), will I still download the entire 10GB when fetching from the repo from the first time, even with sparse checkout?

Community
  • 1
  • 1
Paul Draper
  • 78,542
  • 46
  • 206
  • 285
  • 1
    Yes, but this is already covered in one of the other answers to that question (udondan's), is it not? Can you explain what specifically you're asking that *isn't* covered by that answer? –  Jun 17 '15 at 23:22
  • 2
    @hvd, udondan's answer does not answer this. It does mention a shallow clone, which omits by revision, not by path. I am asking about sparse checkout (paths), not shallow clone (revisions). – Paul Draper Jun 17 '15 at 23:32
  • Yes, I'm aware of that. udondan's answer says yes, a sparse checkout will still require downloading the entire 10GB, and if you wish to avoid that, you can create a shallow clone. –  Jun 18 '15 at 05:44

1 Answers1

-3

Yes.

$ git init
$ git config core.sparsecheckout 1
$ echo build > .git/info/sparse-checkout
$ git remote add origin git://github.com/XhmikosR/notepad2-mod
$ git pull origin master
remote: Counting objects: 6662, done.
remote: Total 6662 (delta 0), reused 0 (delta 0), pack-reused 6662
Receiving objects: 100% (6662/6662), 5.10 MiB | 1.38 MiB/s, done.

VS

$ git clone git://github.com/XhmikosR/notepad2-mod
Cloning into 'notepad2-mod'...
remote: Counting objects: 8405, done.
remote: Total 8405 (delta 0), reused 0 (delta 0), pack-reused 8405
Receiving objects: 100% (8405/8405), 9.69 MiB | 1.44 MiB/s, done.

Disclaimer: I am not certain this is correct, but it should help your cause. Sometimes the best way to get a right answer is to post a wrong one.

Using Git Sparse Checkout

Zombo
  • 1
  • 62
  • 391
  • 407
  • 3
    That difference is because in your first version, you only pull the master branch. If you change `git pull origin master` to `git remote update`, for instance, you'll see that same number 9.69 MiB. –  Jun 19 '15 at 08:01
  • If you would prefer me copying your answer, except edited it to make a more accurate comparison, I'll do so. It would normally be considered rude so I'd rather give you the opportunity to fix up your answer (which would make my answer redundant), but I'll leave it up to you, if you want me to just say so. –  Jun 19 '15 at 21:47