worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

Feature Request: add exclude options on `wt step copy-ignored`

Open gmetzker opened this issue 8 months ago • 5 comments

Would it be possible to have some sort of --exclude option to wt step copy-ignored. I really like most of what wt step copy-ignored is doing as a post-start step but I was looking to have something like: copy everything from .gitignore except directory-X

I wasn't partial to .worktreeinclude as I really don't want to manage another file in each repo and really just wanted an exclude option.

Any other options?

gmetzker avatar Mar 18 '26 22:03 gmetzker

Thanks for the suggestion! I searched the codebase and there's no --exclude CLI option today. The only filtering mechanism is the .worktreeinclude file.

One workaround that might help: .worktreeinclude uses gitignore-style patterns including negation, so you can get "copy everything except directory-X" with:

# .worktreeinclude
*
!directory-X/

This avoids listing every directory you do want — just a wildcard plus exclusions. It's not as ergonomic as a CLI flag, but it works today without any changes.

That said, I understand preferring a CLI --exclude flag over managing an extra file. I'll leave it for a maintainer to evaluate and prioritize.

worktrunk-bot avatar Mar 18 '26 22:03 worktrunk-bot

does .worktreeinclude suffice?

max-sixty avatar Mar 19 '26 00:03 max-sixty

Question about how .worktreeinclude works - does it ONLY include what you put in the list? (out of what is in .gitignore)?

ortonomy avatar Mar 19 '26 07:03 ortonomy

By default (no .worktreeinclude file), wt step copy-ignored copies all gitignored files to the new worktree.

When .worktreeinclude exists, it acts as a whitelist filter on that set — only gitignored files that also match a pattern in .worktreeinclude get copied. So yes, it only includes what you list (out of what's in .gitignore).

To get "everything except directory-X", you'd use:

*
!directory-X/

The * matches all gitignored files, and !directory-X/ negates (excludes) that directory. It uses standard gitignore pattern syntax.

worktrunk-bot avatar Mar 19 '26 07:03 worktrunk-bot

The new [step.copy-ignored] add in #1667 works for me. Thanks

gmetzker-4c avatar Apr 22 '26 18:04 gmetzker-4c