Worktree Setup Files
When JarVS creates a git worktree, it can automatically copy files and run scripts to get the new directory ready. Two optional config files control this behavior.
.worktreeinclude
Place a .worktreeinclude file at the root of your repository to list files that should be copied into every new worktree. This is useful for files that are git-ignored but required to run your project, such as environment variables or build configs.
Each line is a glob pattern. Lines starting with # are comments and blank lines are ignored.
.env .env.local node_modules
Only git-ignored files are copied. If a pattern matches a tracked file, it is skipped — tracked files are already part of the worktree through git itself.
.postworktree.sh
If a .postworktree.sh script exists at the root of your repository, JarVS will run it inside the new worktree directory after creation. Use it to install dependencies, generate files, or perform any other setup.
#!/bin/bash npm install npx prisma generate
The script runs with bash and the working directory is set to the new worktree. If the script fails, a warning is logged but the worktree is still created successfully.
Execution Order
- Git worktree is created from the selected branch.
.worktreeincludepatterns are expanded and matching git-ignored files are copied from the source repo into the worktree..postworktree.shis executed inside the worktree directory (if present).
Both steps are optional and independent. You can use one without the other, or neither.
Example
A typical setup for a Node.js project might look like this:
.worktreeinclude
.env .env.local
.postworktree.sh
#!/bin/bash npm install
This copies your environment files into the worktree, then installs dependencies. The worktree is ready to use immediately.