git version 2.25.1
I'm trying to clone only a specific directory from the git repository using the below command ;
git clone --depth 1 --filter=blob:none --sparse https://github.com/gitexpert/testGithub.git
cd testGithub
git sparse-checkout set banana
I'm getting this output:
hello.rb
readme.text
test.md
but the expected output should be :
I want to clone only the root folder banana not the one from the src folder.
also, how do I pull the local copy up-to-date with the remote repository?

git sparse-checkout settakes file name patterns that are similar to.gitignoreentries, sobananameans everything namedbananaas either a directory or a file name. You would want/bananato limit it to just thebananatop level directory. Note that this (and.gitignoreand.gitattributes) is one of the few places that Git considers things to be "folders-and-files" rather than just one big file name with embedded slashes.git sparse-checkouthas something called cone mode that makes it go faster. Your setup is a candidate for this mode. See thegit sparse-checkoutdocumentation for details.--filtermakes a partial clone. This is separate from sparse checkout, though combining the two can help save a lot of space in extremely large monorepos. The partial clone code is, however, not really ready for everyday use by many people. It can be extremely network-intensive and inefficient, for instance.