For example, I have /tmp/foo
Git repository, etc
branch and non-empty /etc
directory. I wish to attach the /etc
directory as a worktree to the etc
branch. git worktree add /etc etc
won't work due to "already exists".
I saw some old discussion in between Git developers but not sure was this case/issue solved nowadays.
I understand that I can exec something like the following:
git worktree add /tmp/bar etc
- Rename
/tmp/foo/.git/worktrees/bar
to/tmp/foo/.git/worktrees/etc
- Edit
/tmp/foo/.git/worktrees/etc/gitdir
- Create proper
/etc/.git
file which pointing to/tmp/foo/.git/worktrees/etc
But I am wondering is there some more handy way to do that in the modern Git?