A working copy of version controlled code which doesn't include the whole repository.
Questions tagged [sparse-checkout]
102 questions
1577
votes
20 answers
How do I clone a subdirectory only of a Git repository?
I have my Git repository which, at the root, has two sub directories:
/finisht
/static
When this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so:
svn co…
Nick Sergeant
- 29,184
- 12
- 34
- 44
492
votes
21 answers
How to sparsely checkout only one single file from a git repository?
How do I checkout just one file from a git repo?
Arthur Ulfeldt
- 87,736
- 24
- 197
- 278
242
votes
23 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
228
votes
9 answers
How to git reset --hard a subdirectory?
UPDATE²: With Git 2.23 (August 2019), there's a new command git restore that does this, see the accepted answer.
UPDATE: This will work more intuitively as of Git 1.8.3, see my own answer.
Imagine the following use case: I want to get rid of all…
krlmlr
- 22,030
- 13
- 107
- 191
166
votes
9 answers
Checkout subdirectories in Git?
Is it possible to check out subdirectories of a repository in Git?
Imagine I am setting up a new WordPress installation. I will create two new directories for my plugin and theme customization:
wordpress/wp-content/plugins/myplugins/…
Annika Backstrom
- 13,337
- 5
- 38
- 52
160
votes
7 answers
Can you do a partial checkout with Subversion?
If I had 20 directories under trunk/ with lots of files in each and only needed 3 of those directories, would it be possible to do a Subversion checkout with only those 3 directories under trunk?
readonly
- 306,152
- 101
- 198
- 201
70
votes
7 answers
Sparse checkout in Git 1.7.0?
With the new sparse checkout feature in Git 1.7.0, is it possible to just get the contents of a subdirectory like how you can in SVN? I found this example, but it preserves the full directory structure. Imagine that I just wanted the contents of the…
davr
- 18,038
- 16
- 73
- 98
64
votes
3 answers
Jenkins and Git sparse checkouts
I have a large repository in Git. How do I create a job in Jenkins that checks out just one sub-folder from the project?
Pavel Chuchuva
- 21,289
- 9
- 93
- 110
36
votes
5 answers
Change depth in existing SVN working copy without redownloading
I have a working copy of an entire SVN repository, but I want to change it into a sparse working copy because of disk space issues.
One way to do this would be:
svn up --set-depth immediates projects
svn up --set-depth infinity projects/project1
svn…
Bart van Heukelom
- 40,403
- 57
- 174
- 291
34
votes
6 answers
Cloning only a subdirectory with git
I have a git repository that includes subdirectories. Example dirA/dirB.
Is there any way to do a git clone on a Unix server to pull only files from a subdirectory (dirB)?
Is there some other git command other than clone that will do this?
How do I…
user1526912
- 10,370
- 11
- 49
- 81
26
votes
2 answers
TortoiseSVN: Adding additional files after using SVN Checkout dialog "Only this item" option
Our department is planning on using the "SVN Checkout" option within Tortoise SVN. In that dialog, we select the "Only this item" option and then we click the "Choose items" button and choose all the relevant files we want to check-out. Let's…
MacGyver
- 16,700
- 37
- 145
- 233
23
votes
6 answers
github/git Checkout Returns 'error: invalid path' on Windows
When I attempt to checkout a repository from github I get the error:
error: invalid path 'configs/perl-modules/DIST.64/perl-HTML-Tree-1:5.03-1.el6.noarch.rpm'
I suspect the issue is that the path contains a : which is illegal on Windows.
After…
wdtj
- 1,089
- 1
- 9
- 16
20
votes
3 answers
Set Git submodule to shallow clone & sparse checkout?
Many vendor Objective-C libraries (e.g., facebook-ios-sdk) instruct you to copy a certain subset of its repo's files/dirs into your Xcode project. One problem with this is then you do not know what revision of the vendor code you have. Another is…
ma11hew28
- 106,283
- 107
- 420
- 616
16
votes
5 answers
Git sparse checkout with exclusion
According to this thread, exclusion in Git's sparse-checkout feature is supposed to be implemented. Is it?
Assume that I have the following structure:
papers/
papers/...
presentations/
presentations/heavy_presentation
presentations/...
Now I want…
krlmlr
- 22,030
- 13
- 107
- 191
13
votes
3 answers
Why do excluded files keep reappearing in my git sparse checkout?
I use the GCC git mirror and because I only use the C and C++ front ends I use git's sparse checkout feature to exclude the hundreds of files I don't need:
$ git config core.sparseCheckout
true
$ cat .git/info/sparse-checkout…
Jonathan Wakely
- 153,269
- 21
- 303
- 482