According to this thread, exclusion in Git's sparse-checkout
feature is supposed to be implemented. Is it?
Assume that I have the following structure:
papers/
papers/...
presentations/
presentations/heavy_presentation
presentations/...
Now I want to exclude presentations/heavy_presentation
from the checkout, while leaving the rest in the checkout. I haven't managed to get this running. What's the right syntax for this?
"Sparse checkout" allows populating the working directory sparsely. It uses the skip-worktree bit (see git-update-index[1]) to tell Git whether a file in the working directory is worth looking at. If the skip-worktree bit is set, and the file is not present in the working tree, then its absence is ignored.
Partial clone is a performance optimization that “allows Git to function without having a complete copy of the repository. The goal of this work is to allow Git better handle extremely large repositories.” Git 2.22. 0 or later is required.
Sadly none of the above worked for me so I spent very long time trying different combination of sparse-checkout
file.
In my case I wanted to skip folders with IntelliJ IDEA configs.
Here is what I did:
Run git clone https://github.com/myaccount/myrepo.git --no-checkout
Run git config core.sparsecheckout true
Created .git\info\sparse-checkout
with following content
!.idea/*
!.idea_modules/*
/*
Run 'git checkout --' to get all files.
Critical thing to make it work was to add /*
after folder's name.
I have git 1.9
I would have expected something like the below to work:
/*
!presentations/heavy_presentation
But it doesn't. And I did try many other combinations. I think the exclude is not implemented properly and there are bugs around it (still)
Something like:
presentations/*
!presentations/heavy_presentation
does work though and you will get the presentations folder without the heavy_presentation folder.
So the workaround would be to include everything else explicitly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With