Skip to content

Commit 3e57463

Browse files
akirayamamotoclaude
andcommitted
Update README with project goals, configuration docs, and AI tool workaround
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent dffa4eb commit 3e57463

1 file changed

Lines changed: 37 additions & 13 deletions

File tree

README.md

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# git-hooks-toolbox
22

3-
Cross-platform git hooks for Octopus Deploy developer workflows.
3+
Seamless, non-intrusive git hooks for worktree-heavy workflows.
4+
5+
Works out of the box — no changes to your existing `git worktree` commands. AI tools like Claude Code and Codex use normal git operations and benefit automatically. Supports macOS and Windows.
46

57
## Prerequisites
68

79
- [Python 3.12+](https://www.python.org/downloads/)
810
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
911

10-
> **Windows:** Ensure `python3` (or `python`) is on your PATH in Git Bash. The hook bootstraps
11-
> its own dependencies via `uv` automatically.
12-
1312
## Setup
1413

1514
```bash
@@ -23,23 +22,48 @@ git config --global core.hooksPath ~/.git-hooks-toolbox
2322
git -C ~/.git-hooks-toolbox pull
2423
```
2524

25+
## Configuration
26+
27+
Hooks use a `.worktreeinclude` file (gitignore syntax) to determine which local files to copy when creating a new worktree.
28+
29+
**Priority order:**
30+
31+
1. `.worktreeinclude` in the repo root (checked in or local)
32+
2. `~/.worktreeinclude` (user-wide fallback)
33+
34+
See [`example.worktreeinclude`](./example.worktreeinclude) for common patterns (`.env`, `appsettings.Local.json`, Terraform vars, etc.).
35+
36+
**Override source worktree** (optional):
37+
38+
If automatic source detection doesn't pick the right worktree, set `GIT_WORKTREE_SOURCE` to the path of the worktree to copy from:
39+
40+
```bash
41+
GIT_WORKTREE_SOURCE=/path/to/source git worktree add ../my-branch
42+
```
43+
44+
**AI tools (Claude Code, Codex, etc.):**
45+
46+
AI agents invoke git from subprocesses, which breaks the process ancestry detection. Add the following to your `CLAUDE.md` or `AGENTS.md` so the agent always passes the correct source worktree:
47+
48+
```
49+
When creating git worktrees, always prefix the command with GIT_WORKTREE_SOURCE="$PWD":
50+
51+
GIT_WORKTREE_SOURCE="$PWD" git worktree add ../<branch> -b <branch> main
52+
```
53+
2654
## Hooks
2755

2856
### `post-checkout`
2957

30-
Automatically copies local files from source worktree to newly created worktrees.
58+
Automatically copies local files from the source worktree to a newly created worktree.
3159

32-
- Runs on `git worktree add`.
33-
- Copies matching local files from source worktree to new worktree.
34-
- Uses patterns from repo `.worktreeinclude` or fallback `~/.worktreeinclude`.
35-
- Never overwrites existing files.
36-
37-
See `example.worktreeinclude` for pattern file examples.
60+
- Triggers on `git worktree add`
61+
- Detects the source worktree automatically (by process ancestry, then by most recently modified matching file, then falls back to main worktree)
62+
- Never overwrites existing files in the destination
63+
- Skips gracefully when no pattern file is found
3864

3965
## Development
4066

41-
Run tests:
42-
4367
```bash
4468
uv run --extra test pytest tests -q
4569
```

0 commit comments

Comments
 (0)