This is my commands to git I am running in Windows to sparse checkout folders from repo:
git clone --verbose --filter=blob:none --no-checkout --depth 1 --sparse "https://user:password@github.com/organization/repo-name.git"
cd ./repo-name
git config core.sparseCheckout true
git sparse-checkout init
git sparse-checkout add /MainFolder !/MainFolder/Subfolder
git sparse-checkout add /AnotherFolder
...
git checkout --progress --force
...
and everything working perfectly on my machine (tm) but all the sudden it stop working on another Windows machine (in Powershell or CMD) with error:
fatal: specify directories rather than patterns. If your directory starts with a '!', pass --skip-checks
I guess it is somehow in line: git sparse-checkout add /MainFolder !/MainFolder/Subfolder but what ?
After a lot of try/catches I found out that this command works OK:
git sparse-checkout add MainFolder
but this command (with slash before folder name)
git sparse-checkout add /MainFolder
result in error: fatal: specify directories rather than patterns (no leading slash)....
What I need to set/configure on second machine so it continue to work as on my machine (including !/folder exclusion patterns) ?
P.S. Both machines using git version: git version 2.37.1.windows.1
@torek gave a correct answer but I want to add from myself:
There was a mis-understanding of what mode of sparse checkout is used. What is written above is a pattern style - so to make it work I must disable cone style like this:
git config core.sparseCheckout true
git config --worktree 'core.sparsecheckoutcone' false
and then
git sparse-checkout init
or just use `set' command instead all configurations commands like this:
git sparse-checkout set --no-cone
anyway - I must disable cone mode so above git commands will work (including the special symbols to exclude folders: ! and other staff)
Thanks @torek