每工作树本地排除

Per-worktree local exclusion

我想在 worktree 上使用本地文件排除。我尝试将文件名添加到 .git/worktrees/$worktreename/info/exclude,但没有成功。类似的文件 .git/info/exclude 有效,但适用于所有工作树,而不仅仅是主要的。

but it doesn't take

我在 .git/worktrees official layout documentation 中没有看到 info/exclude

一种解决方法是具有特定于分支的 .gitignore 内容。
这意味着将未跟踪的文件添加到工作树 .gitignore 仍然是最佳选择。
您可以使用更新索引命令 seen here.

忽略对该(跟踪的).gitignore 文件的修改
git update-index --assume-unchanged -- .gitignore

这允许您进行 local 排除。