{"thread":{"id":"51902","subject":"Why is \"Sparse checkout leaves no entry on working directory\" fatal?","startedAt":"2019-09-23T10:32:29Z","lastAt":"2019-09-23T10:32:29Z","messageCount":1,"participants":["Josef Wolf"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"382763","messageId":"20190923100526.GA30443@raven.inka.de","threadId":"51902","inReplyTo":null,"subject":"Why is \"Sparse checkout leaves no entry on working directory\" fatal?","fromName":"Josef Wolf","fromEmail":"jw@raven.inka.de","sentAt":"2019-09-23T10:05:26Z","receivedAt":"2019-09-23T10:32:29Z","isPatch":false,"sender":{"key":"jw@raven.inka.de","avatar":null},"body":"Hello,\n\nI am trying to add a file to an arbitrary branch without touching the current\nworktree with as little overhead as possible.\n\nFor this, the sparse-checkout feature in conjuntion with the \"shared\nrepository\" feature seems to be perfect.\n\nThe basic idea goes like this:\n\n\n   TMP=`mktemp -d /var/tmp/test-XXXXXXXXX`\n   GD=$TMP/git\n   WD=$TMP/wd\n   \n   git --work-tree $WD --git-dir $GD clone -qns -n . $GD\n   git --work-tree $WD --git-dir $GD config core.sparsecheckout true\n   echo path/of/file/which/I/want/to/create >>$GD/info/sparse-checkout\n   \n   git --work-tree $WD --git-dir $GD checkout -b some-branch remotes/origin/some-branch  # !!!\n   \n   ( cd $WD\n     mkdir -p path/of/file/which/I/want/to\n     echo huhuh >path/of/file/which/I/want/to/create\n     git --work-tree $WD --git-dir $GD add path/of/file/which/I/want/to/create\n     git --work-tree $WD --git-dir $GD commit\n     git --work-tree $WD --git-dir $GD push\n   )\n   \n   rm -rf $TMP\n\n\nUnfortunately, the marked command errors out with\n\n   \"error: Sparse checkout leaves no entry on working directory\"\n\nand won't create/switch to the branch that is to be modified.\n\nStrange enough, I have some repositories at this machine where the\n.git/info/sparse-checkout file contains only non-existing files and git\nhappily executes this \"git checkout -b XXX remotes/origin/XXX\" command leaving\nthe working tree totally empty all the time.\n\nSomeone understands this inconsistent behaviour?\n\n\n-- \nJosef Wolf\njw@raven.inka.de\n"}]}