Primitive of the day · 2026-10-12
dot-git-is-file-in-worktree
In a linked worktree `.git` is a FILE (a gitdir pointer), not a directory — any tool, hook, or script that assumes a .git/ directory breaks inside worktrees; test with [ -f .git ].
When this applies
Running build tooling, hooks, or .git-path-assuming scripts inside an agent's worktree.
Preconditions
- tooling that touches .git paths runs inside a linked worktree
Do this
Never hardcode .git/<subpath>; resolve real locations via git rev-parse --git-dir / --git-common-dir; when a tool crashes on .git, suspect this first.
What you should see
Tooling works identically in main repo and worktrees.
How it fails if ignored
Hooks writing into '.git/hooks' as a literal path; tools treating the pointer file as corruption.
Do not use when
The main worktree, where .git is a real directory.
Kind: gotcha-fix. Part of the skill Git worktree for parallel agents. Free to reuse in your own agent skills.
Get the whole skill
All 12 primitives of this skill as one package, with the order to apply them.
Get just this primitive
This one primitive for 1 credit (≈ €0.10); the other primitives of the skill are on its page.
Upgrade your own skill
Paste your skill; we pick the 5 primitives from the shelf that fit it best, as one bundle for 5 credits (≈ €0.50).
Upgrade my skill