Sync gitignored config files between git worktrees.
When using git worktrees, gitignored files (like .claude/, .vscode/, .env) don't transfer to new worktrees. This tool syncs them.
go build -o worktree-sync
cp worktree-sync ~/.local/bin/Create .worktree-sync.json in your repo root (add it to .gitignore):
{
"paths": [".claude/", ".vscode/", ".env"],
"exclude": [".vscode/settings.json"]
}Paths ending in / are directories (all files synced recursively). Others are single files.
Create ~/.config/worktree-sync/config.json for paths you want synced in all projects:
{
"paths": [".claude/"]
}Project and global configs are merged. Project exclude can override global paths.
# After creating a new worktree
cd ../my-feature-branch
worktree-sync init # Copy files from main
# Check what would be synced
worktree-sync status
# Manual sync (either direction)
worktree-sync pull # Main -> worktree
worktree-sync push # Worktree -> main
# Before removing a worktree
worktree-sync finish # Sync back to main| Command | Direction | Description |
|---|---|---|
init |
main → worktree | Copy files to new worktree (skips existing) |
pull |
main → worktree | Update worktree from main (overwrites) |
push |
worktree → main | Push changes to main (prompts on conflicts) |
finish |
worktree → main | Same as push, with summary for cleanup |
status |
— | Show what would be synced |
On push/finish, if a file was modified in both main and worktree since last sync, you'll be prompted:
Conflict: .claude/settings.json
Both main and worktree have been modified.
[m] Use main version
[w] Use worktree version
[s] Skip (keep both as-is)
Choice:
- Uses
git worktree listto find the main worktree - Tracks sync state in
.git/worktree-sync-state.json(per worktree) - Compares files by content, not just mtime
- Creates directories as needed when copying
# Install dev tools (goimports, golangci-lint)
make install-tools
# Install pre-commit hook
make install-hooks
# Format code
make fmt
# Run linter
make lint
# Run tests
make test
# Build
make build