git - 如何在删除工作目录后删除 git 工作树分支?

标签 git

我已经删除了它的工作目录,因为这个 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 run git 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/

相关文章:

git - 如何在后台查看git gc的进度?

git - 运行exec任务作为配置阶段的输入

linux - 我可以在 Windows 版 GitBash 上使用 Linux 命令吗

git - 为什么 git fetch 失败并显示 "Could not resolve host: (nil)..."和 https ://github. com/mxcl/homebrew origin?

git - 将我在提交中更改的行中的空格转换为制表符

混帐克隆。如何通过硬链接(hard link)克隆本地仓库?

git - 备份然后用git重置主分支?

git - 如果你使用 git rebase 和 push,对比如果你使用 git pull、merge 和 push,它对项目维护者 merge 的工作有帮助吗?

git - 自定义 commitlint header 格式

git 查看整个 merge 差异