Git Sparse Checkout Exclude

To exclude a directory, first include everything (e.g. /*), then exclude the specific folder or file:

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git config core.sparsecheckout true

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo '/*' > .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ echo '!a_directory_i_want_to_exclude/' >> .git/info/sparse-checkout

uhleeka@uhleeka.local /cygdrive/c/projects/test (master)
$ git read-tree -m -u HEAD

This works with git 2.1.4

$ git --version
git version 2.1.4
Filed Under: Git | Tagged: