如何删除包含子模块的 Git 工作树?

Gin*_*sus 9 git git-submodules git-worktree

让\xe2\x80\x99s 说我有一个包含子模块的Git 存储库:

\n
$ mkdir main-worktree\n$ cd main-worktree\n$ git init\nInitialized empty Git repository in /\xe2\x80\xa6/main-worktree/.git/\n$ git submodule add https://github.com/octocat/Hello-World.git Hello-World\nCloning into \'/\xe2\x80\xa6/main-worktree/Hello-World\'...\nremote: Enumerating objects: 13, done.\nremote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 13\nReceiving objects: 100% (13/13), done.\n$ git commit -m \'Create submodule\'\n[main (root-commit) 66070b6] Create submodule\n 2 files changed, 4 insertions(+)\n create mode 100644 .gitmodules\n create mode 160000 Hello-World\n
Run Code Online (Sandbox Code Playgroud)\n

然后为该存储库创建另一个工作树(包含子模块的工作树):

\n
$ git worktree add ../secondary-worktree\nPreparing worktree (new branch \'secondary-worktree\')\nHEAD is now at 66070b6 Create submodule\n$ cd ../secondary-worktree\n$ git submodule update\nCloning into \'/\xe2\x80\xa6/secondary-worktree/Hello-World\'...\nSubmodule path \'Hello-World\': checked out \'7fd1a60b01f91b314f59955a4e4d4e80d8edf11d\'\n
Run Code Online (Sandbox Code Playgroud)\n

如何删除我secondary-worktree刚刚创建的?我尝试使用git worktree remove,但它给了我一个错误:

\n
$ cd <path-to-main-worktree>\n$ git worktree remove ../secondary-worktree\nfatal: working trees containing submodules cannot be moved or removed\n
Run Code Online (Sandbox Code Playgroud)\n