wt

wt snapshot

Capture local dev overrides (patch + env files) into ~/.worktree-overlays for reuse across worktrees.

Synopsis

wt snapshot

Description

wt snapshot captures your main clone's uncommitted local hacks into ~/.worktree-overlays/<repo>/ so every future worktree can re-apply them automatically.

It writes two things:

  • local.patch — output of git diff HEAD from the main worktree (all tracked-file edits)
  • copies of untracked env files matching [env].patterns, minus anything in [env].exclude

Run this from your MAIN worktree with only local dev hacks in the working tree. Any uncommitted feature work will end up in the patch too — commit or stash it first.

Examples

# First time — from your main clone with local hacks applied
cd ~/repos/myapp
wt snapshot
 
#   saved to /Users/dev/.worktree-overlays/myapp
#   patch:     48 lines
#   env files: 2 (.env, .env.local)
# After changing a local hack — refresh
wt snapshot

Where the overlay is applied

Every wt add and wt setup runs the overlay apply step between env setup and post_setup hooks. In a fresh worktree:

wt add fix-payment-bug
#   ...
#      Applied overlay patch
#   ...

To toggle the behaviour per repo, use the [overlay] section of .worktreerc.

Safety

The overlay lives at ~/.worktree-overlays/<repo>/, outside any git tree. To block accidental commit or push of overlay lines to your remote, install the safety hooks:

wt install-safety-hooks

See wt install-safety-hooks.

Exit Codes

CodeMeaning
0Snapshot written successfully
1Not in a git repository

On this page