wt

wt install-safety-hooks

Install pre-commit + pre-push hooks that block accidental commit/push of overlay lines.

Synopsis

wt install-safety-hooks [repo-path]

Description

wt install-safety-hooks installs two git hooks that refuse commits or pushes whose diff contains lines present in ~/.worktree-overlays/<repo>/local.patch. It is the second half of the overlay workflow — the guard that keeps your local hacks from ever reaching the remote.

  • pre-commit — refuses when any line in the staged diff exactly matches an added line in the overlay patch
  • pre-push — refuses when any commit being pushed introduces such a line

Both hooks preserve any pre-existing hook: the original is moved to <hook>.wt-original and the new wrapper execs it after the safety check passes. This means pre-commit frameworks (Python pre-commit, husky, lint-staged) keep running unchanged.

Re-running is idempotent — hooks with our marker (# wt-safety-hook v1) are overwritten in place, no .wt-original chain is grown.

Options

ArgumentDescription
[repo-path]Target repository (default: current directory)

Examples

# Install into current repo
wt install-safety-hooks
 
# Install into a specific repo
wt install-safety-hooks ~/repos/backend

What gets blocked

$ git commit -m "wip"
wt-safety: BLOCKED - staged diff contains local overlay lines:
  | API_URL = "http://localhost:8080"
  | FEATURE_FLAG_X = True

Fix: unstage those lines (git restore --staged <file>) or edit them out.
Bypass (dangerous): git commit --no-verify
$ git push origin feature-x
wt-safety: BLOCKED push of refs/heads/feature-x - contains local overlay lines:
  | API_URL = "http://localhost:8080"

Fix: remove those lines from the offending commits (rebase, amend, or new commit).
Bypass (dangerous): git push --no-verify

Bypass

git commit --no-verify / git push --no-verify skip the check. Use only when you understand what you're bypassing.

Uninstall

cd <repo>
rm .git/hooks/pre-commit .git/hooks/pre-push
# If a foreign hook was preserved, restore it:
mv .git/hooks/pre-commit.wt-original .git/hooks/pre-commit
mv .git/hooks/pre-push.wt-original   .git/hooks/pre-push

Exit Codes

CodeMeaning
0Hooks installed successfully
1Not in a git repository

On this page