Not able to checkout branch even after removing worktree and running worktree prune
I create a worktree for branch using the following command:
Git add worktree <path> <branch-name>
This created a new worktree for me and checked out the branch at the path
Now I thought of deleting/removing the worktree. Ran following commands:
rm -rf <path>
git worktree prune
This should ideally remove the worktree and remove the reference for that path too. So now I should be able to checkout the branch. But when I run following command to checkout to that branch:
git checkout <branch-name>
I get this error:
fatal: '<branch-name>' is already checked out at ''
Could someone help me with what is going on.
I worked around this by erasing .git/worktrees/<branch-name>
from the repository directory.
I think the right command is:
git worktree prune