我已经删除了它的工作目录,因为这个 git 工作树不再有用,然后我在主存储库的目录下 git branch -D pubsub-sketch-tree
。抛出错误:
error: Cannot delete branch 'pubsub-sketch-tree' checked out at '/Users/zhouhancheng/编程/github_own/sketch_worktree/pubsub-sketch_tree'
但 '/Users/zhouhancheng/编程/github_own/sketch_worktree/pubsub-sketch_tree' 已被删除。
最佳答案
您正在使用 git worktree
,所以答案在 the git worktree
documentation 中:
When you are done with a linked working tree you can simply delete it. The working tree’s administrative files in the repository (see "DETAILS" below) will eventually be removed automatically (see
gc.worktreePruneExpire
in git-config(1)), or you can rungit worktree prune
in the main or any linked working tree to clean up any stale administrative files.
(强调我的)。如果 Git 认为它已在辅助工作树中 checkout ,则不会让您删除该分支。如果辅助工作树已被删除,但 Git 尚未发现这一事实,只需运行 git worktree prune
以告诉 Git 去检查。
关于git - 如何在删除工作目录后删除 git 工作树分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44109234/