iampolo iampolo - 3 years ago 297
Git Question

How to disable sparse checkout after enabled?

I enabled a sparse checkout

git init
git remote add <url>
git config --global core.sparseCheckout true
echo "assets" >> .git/info/sparse-checkout
git pull origin master

Git checked out only the assets folder for me

But now, I want to enable full branch checkout again (checkout folders/files), but it doesn't seem to work.

1) first I disabled config

git config --global core.sparseCheckout false

2) removed the entries in .git/info/sparse-checkout

But git didn't checkout any of the other folders/files for me, it seems it is sticking to 'assets' folder.

Could anyone tell me how can I reset/disable this sparse checkout without creating a new repo.?

Answer Source

You can see an example of "undoing" a sparse checkout in this script by Roscoe A. Bartlett:

git read-tree is important.

echo "Undoing sparse checkout"

# Get the full tree back
echo "*" > $SC_FILE
git config core.sparsecheckout true
git read-tree --reset -u HEAD

# Wipe out all traces of sparse checkout support
git config core.sparsecheckout false

The article "Adventures in Git - SparseCheckouts" by Rich Somerfield propose a similar option (also valid for submodules):

echo "/*" > .git/info/sparse-checkout
echo "/*" > .git/modules/<MODULEPATH>/info/sparse-checkout
git read-tree -mu HEAD
git config core.sparseCheckout false

braham-snyder adds in the comments that updating a .git/info/sparse-checkout (to checkout and track additional files) can be achieved with

git read-tree --dry-run HEAD
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download