我无法删除已消失的本地工作树分支。关键字是本地、工作树分支和消失。即,问题不能删除不存在的分支?和我的不匹配。
当我尝试在调用之前删除工作树文件夹时会发生这种情况git branch -d
。观察:
MINGW64 /d/Tmp
$ mkdir repoA
MINGW64 /d/Tmp
$ cd repoA
MINGW64 /d/Tmp/repoA
$ git init
Initialized empty Git repository in D:/Tmp/repoA/.git/
MINGW64 /d/Tmp/repoA (master)
$ echo a > a
MINGW64 /d/Tmp/repoA (master)
$ git add .
MINGW64 /d/Tmp/repoA (master)
$ git commit -a -m'added a'
[master (root-commit) 2cff3c3] added a
1 file changed, 1 insertion(+)
create mode 100644 a
MINGW64 /d/Tmp/repoA (master)
$ git worktree add -b branch-b ../repoB master
Preparing worktree (new branch 'branch-b')
HEAD is now at 2cff3c3 added a
MINGW64 /d/Tmp/repoA (master)
$ rm -rf ../repoB
MINGW64 /d/Tmp/repoA (master)
$ git branch -d branch-b
error: Cannot delete branch 'branch-b' checked out at 'D:/Tmp/repoB'
MINGW64 /d/Tmp/repoA (master)
$ git branch -d branch-b -f
error: Cannot delete branch 'branch-b' checked out at 'D:/Tmp/repoB'
MINGW64 /d/Tmp/repoA (master)
$ git --version
git version 2.19.1.windows.1
更新:
git worktree prune
可以删除工作树,但branch-b
仍然存在:
$ git worktree list
D:/Tmp/repoA 2cff3c3 [master]
D:/Tmp/repoB 2cff3c3 [branch-b]
$ git worktree prune
$ git worktree list
D:/Tmp/repoA 2cff3c3 [master]
$ git branch -vv
branch-b 2cff3c3 added a
* master 2cff3c3 added a
如何删除branch-b
我不再想要的?