Questions tagged [git-sparse-checkout]
29 questions
283
votes
24 answers
Retrieve a single file from a repository
What is the most efficient mechanism (in respect to data transferred and disk space used) to get the contents of a single file from a remote git repository?
So far I've managed to come up with:
git clone --no-checkout --depth 1…
Theozaurus
239
votes
16 answers
Is it possible to do a sparse checkout without checking out the whole repository first?
I'm working with a repository with a very large number of files that takes hours to checkout. I'm looking into the possibility of whether Git would work well with this kind of repository now that it supports sparse checkouts but every example that I…

dromodel
- 9,581
- 12
- 47
- 65
13
votes
2 answers
How do I clone, fetch or sparse checkout a single directory or a list of directories from git repository?
How do I clone, fetch or sparse checkout a single file or directory or a list of files or directories from a git repository avoiding downloading the entire history or at least keeping history download at minimum?
For the benefit of people landing…

Richard Gomes
- 5,675
- 2
- 44
- 50
10
votes
2 answers
How to do submodule sparse-checkout with Git?
There are a lot of articles and SO questions about sparse-checkout. Unfortunately I did not find concrete examples. I would like to get this following example work:
Create a submodule
cd ~
mkdir sub && cd $_
git init
mkdir foo && touch $_/foo
mkdir…

nowox
- 25,978
- 39
- 143
- 293
7
votes
1 answer
failed to initialize sparse-checkout
I'm getting the below error when i try to clone a folder "banana" from git repository using sparse filter;
git clone --depth 1 --filter=blob:none --sparse https://github.com/gitexpert/testGithub.git
cd testGithub
git sparse-checkout set banana
GIT…

itgeek
- 549
- 1
- 15
- 33
6
votes
0 answers
How can I sparse checkout a subdirectory from git without checking out its parent directories?
I am trying to sparse-checkout a subdirectory from my git repository.
The repository contains multiple plugins for wordpress and I want to check them out one by one. With the below posted solutions I have encountered the problem that EVERYTIME I…

chris9r
- 61
- 3
4
votes
1 answer
Git "error : invalid path" during git checkout
When I'm trying to checkout to another branch from cmd:
git checkout Datascience_With_Python --
this error is occuring:
error: invalid path 'Datascience_With_Python/Machine Learning/Tutorials/Steps for Machine Learning "MLOps"/README.md'
error:…

rica_programmer
- 41
- 1
- 3
4
votes
0 answers
Can sparse-checkout patterns be added to .gitmodules?
Let's say I have a git submodule and I want to to enable sparse-checkout on it. Is it possible to do so and add that file to the repository for other people that clone? The git submodule gets added to /.gitmodules but the sparse checkout file for…

Evan Carroll
- 78,363
- 46
- 261
- 468
3
votes
1 answer
git sparse-checkout ignore specific file type
I have a git repository with a bunch of large csv in them, which I don't want to clone, so I came across git sparse-checkout and this post: https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/
From this post I took…

Frode Akselsen
- 616
- 2
- 8
- 23
2
votes
1 answer
Git Sparse checkout ignore a bad directory
I have a directory name "[afdsklj]" in my git repo. It seems that git sparse checkout still gives me fatal error invalid argument when it tries to create the new directory. Is there someway to have git exclude this bad directory altogether?

N M
- 596
- 4
- 18
2
votes
2 answers
Sparse checkouts - how does it works
I've been looking for a way to clone only a sub directory of one of my project. Obviously I found this answer. it is well designed and the step-by-step solution explain well how to implement this. Now at the end it refers to documentation which…

scharette
- 9,437
- 8
- 33
- 67
2
votes
1 answer
Git copy only specific files from remote
I am trying to understand how (and if it is possible) to copy only specific files of a specific directory from remote in Git. (not interested in continuing working on those files or getting the history)
For example, say the remote master branch…

Yannis
- 1,682
- 7
- 27
- 45
2
votes
0 answers
Git - Sparse checkout of submodule doesn't clone?
We have a submodule in our super project. That submodule uses a sparse checkout (think of the submodule as a large core library where we choose which parts are necessary for the current project). Despite the checkout working perfectly with its…

Steven Sauer
- 31
- 4
1
vote
1 answer
How to prevent git clone --filter=blob:none --sparse from downloading files on the root directory?
As explained at How do I clone a subdirectory only of a Git repository? the best way I've found so far to download all files in a Git subdirectory only is:
git clone --depth 1 --filter=blob:none --sparse \
…

Ciro Santilli OurBigBook.com
- 347,512
- 102
- 1,199
- 985
1
vote
0 answers
how to clone specific folder from git using --sparse
git version 2.25.1
I'm trying to clone only a specific directory from the git repository using the below command ;
git clone --depth 1 --filter=blob:none --sparse https://github.com/gitexpert/testGithub.git
cd testGithub
git sparse-checkout set…

itgeek
- 549
- 1
- 15
- 33