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.
A Git worktree is a linked copy of your Git repository, allowing you to have multiple branches checked out at a time. A worktree has a separate path from your main working copy, but it can be in a different state and on a different branch.
To remove a locked worktree, specify --force twice. With add , create a new branch named <new-branch> starting at <commit-ish> , and check out <new-branch> into the new worktree. If <commit-ish> is omitted, it defaults to HEAD . By default, -b refuses to create a new branch if it already exists.
prune Prune working tree information in $GIT_DIR/worktrees. remove Remove a working tree. Only clean working trees (no untracked files and no modification in tracked files) can be removed. Unclean working trees or ones with submodules can be removed with --force.
Create as many worktrees for a detached HEAD as you want to. You can run git worktree add /path/foo1 refs/heads/master , git worktree add /path/foo2 refs/heads/master , ..., git worktree add /path/fooN refs/heads/master . Reset develop to master . In "project_develop" worktree, run git reset master --hard .
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With