Why does git worktree add create a branch, and can I delete it?

As the other guys answer this question, I put commands to delete the folder, delete worktree and delete branch here:

first, list all of your worktrees to double check…

$ git worktree list

then, delete the folder of the worktree

$ rm -rf path/to/worktree

after that, delete the worktree itself

$ git worktree prune

in case you have more than one worktree, the above command only prune the worktree that its path doesn’t exist anymore, so don’t worry!

finally, delete the branch (same branch-name as the worktree)

$ git branch -D <branch-name>

Leave a Comment

tech