I used git worktree add
to create a new worktree. I noticed that is has created a new branch in the repo with the same name as the worktree. What is this branch for?
I have checked out an other, pre-existing branch in the second worktree. Am I free to delete the branch that git worktree add
created?
git worktree add /path/to/foo
fail without a-b
or-B
or final argument, instead of defaulting to usingfoo
here, but my guess is they thought it was more convenient to default to usingfoo
here. – Buseygit worktree add --detach </path/to/worktree>
and you will get a detached head instead. This is what I always do. If you are planning to checkout some existing branch, you can dogit worktree add </path/to/worktree> <my-branch>
. – Shirigit worktree --remove
(for Git 2.17+, Q2 2018): see my answer here – Eluviation