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 can find does the following:
git clone <path>
git config core.sparsecheckout true
echo <dir> > .git/info/sparse-checkout
git read-tree -m -u HEAD
The problem with this sequence of commands is the original clone also does a checkout. If you add -n to the original clone command, then the read-tree command results in the following error:
error: Sparse checkout leaves no entry on working directory
How can do the sparse checkout without checking out all the files first?
Yes, sparse-checkout download whole stuff to download a folder from git. None of the above methods work for me. To downlaod only a single sample from https://github.com/gearvrf/GearVRf-Demos here is what I did..
For windows user download and install SlikSvn_x84, add this "C:\Program Files (x86)\SlikSvn\bin" to Path environment variable. mac user use alternative svn client.
Use command line :
svn export https://github.com/foobar/Test.git/trunk/foo
Notice the URL format:
The base URL is https://github.com/ /trunk appended at the end
Example :
svn export https://github.com/gearvrf/GearVRf-Demos.git/trunk/gvr-renderableview
I hope this will help someone. ref: https://stackoverflow.com/a/18324458/5710872
Please note that this answer does download a complete copy of the data from a repository. The
git remote add -f
command will clone the whole repository. From the man page ofgit-remote
:Try this:
Now you will find that you have a "pruned" checkout with only files from path/within_repo/to/desired_subdir present (and in that path).
Note that on windows command line you must not quote the path, i.e. you must change the 6th command with this one:
if you don't you'll get the quotes in the sparse-checkout file, and it will not work