Search code examples
gitgit-worktree

Per-worktree local exclusion


I'd like to use local file exclusion on a worktree. I tried adding the file name to .git/worktrees/$worktreename/info/exclude but it doesn't take. The analogous file .git/info/exclude works, but applies to all worktrees, not just the main one.


Solution

  • but it doesn't take

    I do not see an info/exclude in .git/worktrees official layout documentation.

    A workaround would to have a branch-specific .gitignore content.
    That means adding your untracked file to the worktree .gitignore remains the best option.
    And you can ignore modification on that (tracked) .gitignore file with the update-index command seen here.

    git update-index --assume-unchanged -- .gitignore
    

    That allows you for the local exclusion you are after.