git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Why is "Sparse checkout leaves no entry on working directory" fatal?

From
JWJosef Wolf <jw@raven.inka.de>
Date
Sep 23, 2019, 10:05 UTC
Message-ID
<20190923100526.GA30443@raven.inka.de>
Hello,

I am trying to add a file to an arbitrary branch without touching the current worktree with as little overhead as possible.

For this, the sparse-checkout feature in conjuntion with the "shared repository" feature seems to be perfect.

The basic idea goes like this:
   TMP=`mktemp -d /var/tmp/test-XXXXXXXXX`
   GD=$TMP/git
   WD=$TMP/wd
   
   git --work-tree $WD --git-dir $GD clone -qns -n . $GD
   git --work-tree $WD --git-dir $GD config core.sparsecheckout true
   echo path/of/file/which/I/want/to/create >>$GD/info/sparse-checkout
   
   git --work-tree $WD --git-dir $GD checkout -b some-branch remotes/origin/some-branch  # !!!
   
   ( cd $WD
     mkdir -p path/of/file/which/I/want/to
     echo huhuh >path/of/file/which/I/want/to/create
     git --work-tree $WD --git-dir $GD add path/of/file/which/I/want/to/create
     git --work-tree $WD --git-dir $GD commit
     git --work-tree $WD --git-dir $GD push
   )
   
   rm -rf $TMP
Unfortunately, the marked command errors out with
   "error: Sparse checkout leaves no entry on working directory"
and won't create/switch to the branch that is to be modified.

Strange enough, I have some repositories at this machine where the .git/info/sparse-checkout file contains only non-existing files and git happily executes this "git checkout -b XXX remotes/origin/XXX" command leaving the working tree totally empty all the time.

Someone understands this inconsistent behaviour?
-- 
Josef Wolf
jw@raven.inka.de
Message 1 of 1 in “Why is "Sparse checkout leaves no entry on working directory" fatal?”
  1. Josef WolfSep 23, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.