7

I'm getting the below error when i try to clone a folder "banana" from git repository using sparse filter;

git clone --depth 1 --filter=blob:none --sparse https://github.com/gitexpert/testGithub.git 
cd testGithub
git sparse-checkout set banana

GIT Version : 2.25.1

Error log:

Cloning into 'testGithub'...
fatal: cannot change to '://github.com/gitexpert/testGithub.git': No such file or directory
error: failed to initialize sparse-checkout
itgeek
  • 549
  • 1
  • 15
  • 33
  • 1
    Remove the ```$``` in front of ```https``` and try again? – 过过招 May 13 '22 at 02:10
  • that was just typo, i fixed it . I'm still getting the same error though – itgeek May 13 '22 at 02:13
  • 2
    You asked this *after* you asked why, though the clone succeeded and the `set` succeeded, a subsequent checkout extracted extra files. So did it mysteriously stop working? – torek May 13 '22 at 04:25
  • 2
    I also had the same issue with git 2.25.1. After updating git to 2.37.1 (latest at the time), the problem is gone. – sat63k Aug 02 '22 at 08:30
  • although i haven't verified myself, the issue seems to be addressed in this commit [47dbf10d](https://github.com/git/git/commit/47dbf10d8a5ce8c9b441a16b7698c7d70585dff0). therefore using git v2.26 or higher should fix this issue – starwarswii Oct 04 '22 at 19:46

1 Answers1

5

The solution proposed by @satbekmyrza worked for me. I upgraded git from 2.25.1 to 2.37.3 and now sparse cloning works.

Unfortunately, the git version that is installed through the standard package repos on Ubuntu is 2.25.1 at the time of writing. In order to upgrade to a version higher than 2.25.1, one must install git from the PPA, as described at Download for Linux and Unix (git-scm.com).

outofthecave
  • 477
  • 6
  • 15