A Herdr plugin that copies gitignored files (.env, node_modules/, local configs) from your repository into every new worktree.
It reads two files from the repository root:
| File | Purpose |
|---|---|
.worktreeinclude |
Shared patterns, usually committed |
.worktreeinclude.local |
Your personal patterns, keep it gitignored |
Pure bash, no build step.
herdr plugin install shved270189/herdr-worktreeinclude-localRequirements: Herdr 0.7.0+, macOS or Linux, bash 3.2+, git, jq.
Uninstall or disable other .worktreeinclude plugins first; they react to the same event.
Both files use .gitignore syntax. .worktreeinclude.local is read last, so it can add patterns and negate shared ones:
# .worktreeinclude
.env*
node_modules/# .worktreeinclude.local
!.env.production
.vscode/settings.jsonAdd .worktreeinclude.local to your .gitignore (or ~/.config/git/ignore).
- A path is copied only if it matches a pattern and is gitignored. Tracked files are never copied.
- Existing files in the new worktree are never overwritten.
- Files are read from the source repository root (
repo_rootof the Herdr event). - Copies use copy-on-write where available (
cp -con macOS,cp --reflink=autoon Linux), so large directories are cheap. - A wholly ignored directory is copied as one unit. A
!negationinside such a directory has no effect. - Directories that contain another worktree of the same repository are skipped.
- Symlinks are copied as symlinks.
Herdr shows a notification when a copy fails. The full output of every run is in the plugin log:
herdr plugin log list --plugin herdr-worktreeinclude-local --limit 5Run the script by hand to re-apply the include files to an existing worktree:
bash copy-worktreeinclude.sh /path/to/repo /path/to/worktreeherdr plugin link "$PWD"
bash test.shMIT