You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
install: sparse clone inherits GIT_DIR and turns on sparse-checkout in the caller's repository #852
When skillshare install runs with GIT_DIR in its environment, the git commands of its sparse subdirectory clone act on the repository that GIT_DIR points at, not on the temporary clone. The result is that core.sparseCheckout is turned on in the caller's repository, and its info/sparse-checkout is set to the skill's subdirectory. The next checkout or merge in that repository then removes every tracked file outside that path.
Git exports GIT_DIR to hooks that run in a linked worktree (git worktree add), so a post-checkout or post-merge hook that runs skillshare install -p triggers this. In our case a merge removed about 28,000 files from the working tree before we noticed.
Reproduction (v0.30.5, git 2.50.1, macOS)
# A host repo that should never be touched
git init -q host && (cd host &&echo a > a && mkdir x &&echo b > x/b && git add -A && git commit -qm init)
# A project that installs one skill from a repo subdirectory
mkdir -p proj/.skillshare &&cd proj && git init -q
cat > .skillshare/config.yaml <<'YAML'targets: - name: universalskills: - name: skillshare source: github.com/runkids/skillshare/skills/skillshareYAML
GIT_DIR=../host/.git skillshare install -p --skip-audit
git -C ../host config --get core.sparseCheckout # true
cat ../host/.git/info/sparse-checkout
# /*# !/*/# /skills/# !/skills/*/# /skills/skillshare/
Without GIT_DIR, the host repository is untouched.
Cause
gitCommand in internal/install/install_git.go passes the whole os.Environ() to git, so GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE and the other repository-local variables reach git sparse-checkout set <subdir> in sparseCloneSubdir. The hooks package already strips these variables (sanitizedGitEnv in internal/hooks/gitcmd.go), but the install path doesn't.
Suggested fix
Apply the same filtering in internal/install's gitCommand, dropping the variables that git rev-parse --local-env-vars lists (or reusing sanitizedGitEnv). Every git call skillshare makes during install runs against a directory it owns, so none of them should inherit a caller's repository variables.
Thanks for tracking this down, and for the repro and the workaround. Sorry it cost you a working tree.
The fix is in #854. skillshare now drops GIT_DIR, GIT_WORK_TREE and the other repository variables from every git command it runs, so install, update and push always work on their own directories. It goes out with the next release; until then, your unset loop is the right workaround.
If you hit anything else from hooks, please open a new issue.
Activity
test(gitenv): fail on new git commands that bypass gitenv
runkids commentedon Nov 11, 2026
Thanks for tracking this down, and for the repro and the workaround. Sorry it cost you a working tree.
The fix is in #854. skillshare now drops GIT_DIR, GIT_WORK_TREE and the other repository variables from every git command it runs, so install, update and push always work on their own directories. It goes out with the next release; until then, your unset loop is the right workaround.
If you hit anything else from hooks, please open a new issue.
docs: prepare the 0.30.6 check --exit-code release
fix(git): keep a caller's GIT_DIR out of skillshare's git commands (r…