failed to initialize sparse-checkout
Asked Answered
N

1

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
Norrie answered 13/5, 2022 at 2:7 Comment(5)
Remove the $ in front of https and try again?Albumen
that was just typo, i fixed it . I'm still getting the same error thoughNorrie
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?Mizzle
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.Minerva
although i haven't verified myself, the issue seems to be addressed in this commit 47dbf10d. therefore using git v2.26 or higher should fix this issueObscenity
S
6

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).

Set answered 26/9, 2022 at 15:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.