GIT 错误:致命:/usr/libexec/git-core/git-submodule 不能在没有工作树的情况下使用

klo*_*lor 8 git git-submodules git-post-receive

我有一个带有子模块的 git repo。

我会在接收后挂钩文件中使用:

git --git-dir="$GIT_DIR" --work-tree="$GIT_WORKDIR1" submodule update --init --recursive 
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

remote: fatal: /usr/libexec/git-core/git-submodule cannot be used without a working tree.  
Run Code Online (Sandbox Code Playgroud)

我没有得到这个问题的解决方案。

我该怎么做才能让它发挥作用?

Cod*_*der 4

如果您重命名了 git 子模块的路径(工作树),您可能会看到此错误。就我而言,我已经更新了路径以.gitmodules匹配我的新路径,并且认为我很好。但是当我git pull稍后执行时,它在旧路径中添加了新文件。这是因为有两个地方定义了模块路径。您还需要更新文件中定义的“工作树” .git/modules/{modulename}/config

这篇文章中也有一些关于工作树的重要细节。