Skip to content

feat(worktrees): support .worktreeinclude for copying gitignored files#128

Merged
pol-rivero merged 2 commits intopol-rivero:mainfrom
userlerueda:a-proposal-for-worktreeinclude
Apr 9, 2026
Merged

feat(worktrees): support .worktreeinclude for copying gitignored files#128
pol-rivero merged 2 commits intopol-rivero:mainfrom
userlerueda:a-proposal-for-worktreeinclude

Conversation

@userlerueda
Copy link
Copy Markdown

Closes #126

Description

When creating a new worktree, automatically copy gitignored files listed in a .worktreeinclude file (gitignore syntax) from the main worktree into the new worktree. Only files that are both gitignored and matched by a pattern are copied — tracked files are never duplicated.

  • Add addWorktreeWithIncludes() which wraps addWorktree() with a best-effort post-creation copy step
  • Add readWorktreeIncludePatterns() to parse the .worktreeinclude file
  • Add getIgnoredFilesMatchingPatterns() using git ls-files --others --ignored and the ignore npm package for .gitignore-spec matching
  • Add copyWorktreeIncludeFiles() with path-traversal protection
  • Wire AddWorktreeDialog to use addWorktreeWithIncludes
  • Add ignore ^7.0.5 as a dependency
  • Add 11 unit tests covering all new functions

Screenshots

Screenshot 2026-04-08 at 9 34 57 PM Screenshot 2026-04-08 at 9 35 33 PM

Release notes

Notes:

userlerueda and others added 2 commits April 8, 2026 21:22
When creating a new worktree, automatically copy gitignored files listed
in a .worktreeinclude file (gitignore syntax) from the main worktree into
the new worktree. Only files that are both gitignored and matched by a
pattern are copied — tracked files are never duplicated.

- Add `addWorktreeWithIncludes()` which wraps `addWorktree()` with a
  best-effort post-creation copy step
- Add `readWorktreeIncludePatterns()` to parse the .worktreeinclude file
- Add `getIgnoredFilesMatchingPatterns()` using `git ls-files --others
  --ignored` and the `ignore` npm package for .gitignore-spec matching
- Add `copyWorktreeIncludeFiles()` with path-traversal protection
- Wire AddWorktreeDialog to use `addWorktreeWithIncludes`
- Add `ignore` ^7.0.5 as a dependency
- Add 11 unit tests covering all new functions

Resolves pol-rivero#126
@pol-rivero pol-rivero force-pushed the a-proposal-for-worktreeinclude branch from 18bba03 to 3856e14 Compare April 9, 2026 06:30
@pol-rivero
Copy link
Copy Markdown
Owner

Just tested it and it works like a charm. Thanks! :)

@pol-rivero pol-rivero merged commit a6f0143 into pol-rivero:main Apr 9, 2026
18 checks passed
@userlerueda userlerueda deleted the a-proposal-for-worktreeinclude branch April 9, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for .worktreeinclude

2 participants