Skip to content

Instantly share code, notes, and snippets.

@bluebycode
Created March 30, 2016 10:02
Show Gist options
  • Save bluebycode/7b6ba55cb2f932b24d6227b2df14757b to your computer and use it in GitHub Desktop.
Save bluebycode/7b6ba55cb2f932b24d6227b2df14757b to your computer and use it in GitHub Desktop.
Working with desired subtrees on git (sparse-checkout)
# Initialize
# Go project folder (empty) and initialize as git
git init
# Fetch tree
git remote add -f origin http://github.com/vrandkode/scratch.git
# Enable sparse-checkout and configure by listing your desired sub-trees
git config core.sparsecheckout true
echo "path/to/dir" >> .git/info/sparse-checkout
echo "path/to/some/file" >> .git/info/sparse-checkout
# Checkout from branch repo [remote] [branch]
git pull origin master
# Done
# 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
git read-tree -mu HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment