'how to clone specific folder from git using --sparse

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.

enter image description here

also, how do I pull the local copy up-to-date with the remote repository?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source