Skip to content

Instantly share code, notes, and snippets.

@mk-pmb
Forked from sumardi/gist:5559896
Created August 20, 2017 18:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mk-pmb/ef2a1bc0e8c50d8bdd4c1566654bdf32 to your computer and use it in GitHub Desktop.
Save mk-pmb/ef2a1bc0e8c50d8bdd4c1566654bdf32 to your computer and use it in GitHub Desktop.
Subdirectory checkouts with Git sparse-checkout
# New repository
mkdir <repo> && cd <repo>
git init
git remote add –f <name> <url>
git config core.sparsecheckout true
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout
git pull <remote> <branch>
# Existing repository
git config core.sparsecheckout true
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout
git read-tree -mu HEAD
# If you later decide to change which directories you would like checked out,
# simply edit the sparse-checkout file and run git read-tree again as above.
# http://schacon.github.io/git/git-read-tree.html#_sparse_checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment