Skip to content

Instantly share code, notes, and snippets.

@xtrmstep
Last active August 12, 2022 05:30
Show Gist options
  • Save xtrmstep/f504fc02c4c7fd61801d961157c4921b to your computer and use it in GitHub Desktop.
Save xtrmstep/f504fc02c4c7fd61801d961157c4921b to your computer and use it in GitHub Desktop.
How to partially download Git repo
Sparse checkout
From scratch (enable)
1) $ git init
2) $ git remote add -f origin URL
3) $ git config core.sparseCheckout true
4) create a file with exclusion rules: /.git/info/sparse-checkout
5) $ git pull origin master
On already cloned folder
To enable
1) $ git config core.sparseCheckout true
2) create a file with exclusion rules: /.git/info/sparse-checkout
3) $ git read-tree -m -u HEAD
To disable
1) update the file with exclusion rules: /.git/info/sparse-checkout, keep only * (include everything)
2) $ git read-tree -m -u HEAD
3) $ git config core.sparseCheckout false
You might need also to do this to restore full checkout
git config core.sparseCheckout false
git read-tree --empty
git reset --hard
See Also
http://schacon.github.io/git/git-read-tree.html#_sparse_checkout
COmmits per day
git log --date=short --pretty=format:%ad | sort | uniq -c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment