gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 13:06:54 26 4
gpt4 key购买 nike

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com