Files in `.git/info/exclude` are no longer hidden after `wt switch` if using jj
It's like .gitignore, but private.
Thanks for the suggestion! This is a feature request rather than a bug, so I'll leave it for a maintainer to evaluate and prioritize.
oh, looks like there is no .git directory in the copy.
Good news — .git/info/exclude actually lives in git's "common directory", which is shared across all worktrees automatically. A linked worktree's .git file points to <main>/.git/worktrees/<name>/, but info/exclude stays in the shared <main>/.git/info/exclude and applies to every worktree.
You can verify with:
# From any linked worktree:
git rev-parse --git-common-dir
# → points to the main .git directory
cat "$(git rev-parse --git-common-dir)/info/exclude"
# → shows the shared exclude rules
So there's nothing to copy — your private excludes should already be working in all worktrees created by wt switch.
Fair enough. So, to try to minimize the XY problem factor:
- I use jj
- I have a number of files ignored by both git and jj, thanks to
.git/info/exclude - I
wt switch my-branch - Since my wt config lists
the ignored files get copied correctly[post-create] copy = "wt step copy-ignored && direnv allow" git statusdoes not show them as added- If I
jj st(or any jj operation), this seems to re-add the hidden files, which are then not considered hidden by jj, or by Git
All this to say that I hope this gets taken into account in #926
thanks for the issue @augustebaum
is this a problem with worktrunk? or an issue of how jj handles the exclude file?
It's not quite a problem with wt, I think? jj deals with the exclude file just fine in the normal git setting, but when I create a git worktree jj doesn't know that it's in a worktree; in particular, the .jj directory is ignored in the base tree, so it gets copied by wt step copy-ignored.
I could probably add stuff to my custom post-create hook to make it work, e.g. making use of jj's worktree equivalent (workspaces).
to make sure I understand — is it that we don't want the .jj path copied by wt step copy-ignored? if so, I think that could make sense as a one-off exception
but I'm not familiar enough with jj to know this
@worktrunk-bot maybe you could test & explain what happens in this scenario, what we should do, and make a PR if you're confident in one of the options?
I investigated this and the root cause is clear: wt step copy-ignored copies all gitignored files by default, which includes VCS metadata directories like .jj when they're in .git/info/exclude. These directories contain internal state tied to a specific working directory — copying them to another worktree creates broken state for the colocated VCS.
Git's own .git is implicitly excluded (git never reports it via git ls-files), but other VCS tools colocated with git need explicit exclusion.
#1250 adds a built-in exclusion list for known VCS metadata directories: .jj, .hg, .svn, .sl, .bzr, .pijul. These are always skipped by copy-ignored, regardless of whether .worktreeinclude is used.