git clone, ignoring a directory

A bit late to the party, but: Don’t you want a sparse checkout?

mkdir <repo> && cd <repo>
git init
git remote add –f <name> <url>

Enable sparse-checkout:

git config core.sparsecheckout true

Configure sparse-checkout by listing your desired sub-trees in .git/info/sparse-checkout:

echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout

Checkout from the remote:

git pull <remote> <branch>

See http://jasonkarns.com/blog/subdirectory-checkouts-with-git-sparse-checkout/ for more info.

Leave a Comment