Search code examples
gitsparse-checkout

How do I convert full checkout to sparse checkout?


Having a full checkout of a repository, how can I convert it into a sparse checkout?


Solution

  • Run

    git config core.sparseCheckout true
    

    then create .git/info/sparse-checkout

    /*
    !excluded-dir/
    

    then run

    git checkout master
    

    and excluded-dir will disappear.

    My problem was that I did not put a trailing slash behind the excluded directory in my .git/info/sparse-checkout Much thanks to http://www.richsomerfield.com/post/2014-03-05-adventures-in-git-sparsecheckouts/