Skip to content

skip-worktree — Local Config Flag Quick Reference ​

Mark / unmark ​

bash
# Protect a local config file (use this, not --assume-unchanged)
git update-index --skip-worktree config/local.yaml

# Unprotect
git update-index --no-skip-worktree config/local.yaml

# Wrong flag — assume-unchanged (does not survive checkout/merge)
git update-index --assume-unchanged large-file.bin
git update-index --no-assume-unchanged large-file.bin

Inspect ​

bash
# List all flagged files (S = skip-worktree, h = assume-unchanged)
git ls-files -v | grep -E '^(S|h)'

# Check a specific file
git ls-files -v config/local.yaml

# Show actual diff of a skip-worktree file
git diff HEAD -- config/local.yaml

CI one-liners ​

bash
# CI gate — fail if any flagged files exist
git ls-files -v | grep -q -E '^(S|h)' && { echo "Flagged files found"; exit 1; }

# CI runner — inject secrets into config, protect it
echo "KEY=$SECRET" > config/deploy.yaml && git update-index --skip-worktree config/deploy.yaml

# Pre-commit drift detection
git ls-files -v | grep '^S' | awk '{print $2}' | while read f; do
  git diff --quiet HEAD -- "$f" || { echo "$f differs"; exit 1; }
done

Template sync ​

bash
# Pull upstream changes while keeping local overrides
git update-index --no-skip-worktree config/local.yaml
git stash
git pull
git stash pop
git update-index --skip-worktree config/local.yaml

Flag comparison ​

Action--assume-unchanged--skip-worktree
git status ignoresYesYes
git add . stagesNoNo
git checkout overwritesYesNo
git pull overwritesYesNo
git diff HEAD showsNoYes
Use casePerformance (big files, never change)Config (tracked template, local edits)

Key config ​

No Git config keys — flags are per-file index state, set via git update-index.

Git Master — Git Reference for Every Skill Level