Does sparse checkout affect git fetch?

2.2k views Asked by At

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?

1

There are 1 answers

2
Zombo On

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