Git Sparse Checkout Leaves No Entry on Working Directory

OK, I got this working. As I expected it was not working because of step 5.

The line below works now:

echo "MyProject/*"> .git/info/sparse-checkout

The important thing is to use /, use * and leave no space at the end of the directory.

Then you may pull again or checkout the branch (git checkout master).


if you are working on windows the same as me

you shouldn't get the quotes in the sparse-checkout file, and it will not work and need to use /* at the end of the path

this works for me

echo src/* >> .git/info/sparse-checkout


Solution for Windows users

On Windows, the echo "..." > outfile command creates a file in default system encoding. Git cannot deal with that, it requires the file to be in ASCII.

Powershell

Modify the existing file to become ASCII, assuming you created it already and it doesn't work:

Set-Content .git\info\sparse-checkout "MyProject/*" -Encoding Ascii

Or to create the file with correct encoding from the start:

echo MyProject/* | out-file -Encoding Ascii .git/info/sparse-checkout

Background

See the longer explanation here On Windows git: “error: Sparse checkout leaves no entry on the working directory”

Tags:

Git

Bitbucket