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

后端 未结 6 822
暖寄归人
暖寄归人 2021-02-12 12:08

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

6条回答
  •  情书的邮戳
    2021-02-12 12:39

    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 
    

提交回复
热议问题