0

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.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
Setembru
  • 1
  • 2

1 Answers1

-1

Your question is a bit ambiguous. But I think this should solve your problem:

git remote set-url origin https://github.com/your/repository

Follow the rest steps as usual. Just change your remote origin url.

senarijit1618
  • 389
  • 4
  • 16