Desk Clarity

A field guide to everyday digital problems.

Developer tools / Practical guide

Git Sparse Checkout Cone Mode Still Includes Root Files

Choose directory selection or explicit patterns before trying to exclude a file type.

By ON Lab3 min readSources checked November 10, 2026 (KST)

Cone mode selects directories and includes files from parent directories, including the repository root. It is not a general file-extension exclusion language. Choose the mode according to the working-tree shape you actually need.

Reproduce the boundary in a disposable fixture

Choose directory selection or explicit patterns before trying to exclude a file type.

Use a new empty temporary directory for this fixture. The example creates only local test data. Commands marked with example.invalid do not identify a real service.

git init -q demo
cd demo
git config user.name Fixture
git config user.email fixture@example.invalid
mkdir -p src docs
printf 'root
' > README.md
printf 'code
' > src/app.txt
printf 'docs
' > docs/guide.txt
git add .
git commit -qm fixture
git sparse-checkout set --cone src
test -f README.md
test -f src/app.txt
test ! -f docs/guide.txt
git sparse-checkout list
git ls-files

Observed result

src
README.md
docs/guide.txt
src/app.txt

What the result means

The root README remains even though only src was selected. docs/guide.txt disappears from the sparse working tree but remains tracked, as ls-files shows. This distinguishes visibility from repository membership. Deleting an unwanted file from the selected working tree is not the same as changing sparse rules and may instead stage a real deletion if you add it later.

Choose the correction for your workflow

Use cone mode when directory-based selection matches your task. If your requirement is to exclude every CSV or hide a root file, review the documented non-cone pattern mode and its limitations before migrating rules. Current Git documentation deprecates non-cone mode, so retain cone mode when a directory-based workflow can meet the actual need. Keep the existing rule list and status before changing modes. Do not paste arbitrary gitignore-style negations into a cone-mode configuration and assume they keep cone behavior. After any change, inspect both the visible files and git status rather than only the selection command exit code.

Limits and the next check

Sparse checkout controls the checked-out working tree; it does not by itself guarantee smaller network transfers or remove large historical blobs. Partial clone is a separate mechanism. Uncommitted changes can affect what Git is willing to remove. The fixture uses a clean disposable repository on the installed Git and tests root-file inclusion only. It does not provide a universal exclude-file pattern or claim that a missing directory was deleted from history.

Related: Compare the related workflow boundary.

This isolated example was executed on macOS on November 10, 2026 (KST). Available tools: node v26.5.0, git git version 2.39.3 (Apple Git-145), npm 11.17.0, jq jq-1.7.1-apple. Shell fixtures use Bash and repository-path identity uses Python 3. This checks the illustrated contract, not your project, host service or every tool version.

Sources & further reading