Skip to content

About

Herdr plugin: copy gitignored files matching .worktreeinclude and .worktreeinclude.local into new worktrees

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

herdr-worktreeinclude-local

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.

Install

herdr plugin install shved270189/herdr-worktreeinclude-local

Requirements: 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.

Usage

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.json

Add .worktreeinclude.local to your .gitignore (or ~/.config/git/ignore).

Rules

  • 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_root of the Herdr event).
  • Copies use copy-on-write where available (cp -c on macOS, cp --reflink=auto on Linux), so large directories are cheap.
  • A wholly ignored directory is copied as one unit. A !negation inside such a directory has no effect.
  • Directories that contain another worktree of the same repository are skipped.
  • Symlinks are copied as symlinks.

Troubleshooting

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 5

Run the script by hand to re-apply the include files to an existing worktree:

bash copy-worktreeinclude.sh /path/to/repo /path/to/worktree

Development

herdr plugin link "$PWD"
bash test.sh

License

MIT

About

Herdr plugin: copy gitignored files matching .worktreeinclude and .worktreeinclude.local into new worktrees

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages