I tried to clone only a subdirectory of a Git repository using this answer but it doesn't work.
I use Ubuntu for Windows (WSL) and I used these commands:
$ git init
$ git remote add -f origin <repo-ssh>
$ git config core.sparseCheckout true
$ echo 'FolderName/' >> .git/info/sparse-checkout
$ git pull origin master
fatal: couldn't find remote ref master
$ git pull origin main
* branch main -> FETCH_HEAD
Already up to date.
'FolderName/'
in this case:'Exercise2/'
I don't know how to fix.
And the remote branch name is main
.