Skip to content

Instantly share code, notes, and snippets.

@werty1st
Created September 17, 2013 12:03
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save werty1st/6593431 to your computer and use it in GitHub Desktop.
Save werty1st/6593431 to your computer and use it in GitHub Desktop.
git sparse checkout
What you are trying to do is called a sparse checkout, and that feature was added in git 1.7.0 (Feb. 2012). The steps to do a sparse clone are as follows:
git init <repo>
cd <repo>
git remote add -f origin <url>
This creates an empty repository with your remote. Then do:
git config core.sparsecheckout true
Now you need to define which files/folders you want to actually check out. This is done by listing them in .git/info/sparse-checkout, eg:
echo some/dir/ >> .git/info/sparse-checkout
echo another/sub/tree >> .git/info/sparse-checkout
Last but not least, update your empty repo with the state from the remote:
git pull origin master
damit man später git pull ohne origin master machen kann muss man das noch in ie .git/config eintragen
[branch "master"]
remote = origin
merge = refs/heads/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment