GIT错误:致命:没有工作树,无法使用/usr/libexec/git-core/git-submodule [英] GIT error: fatal: /usr/libexec/git-core/git-submodule cannot be used without a working tree
问题描述
我有一个带有子模块的git repo.
I have a git repo with a submodule.
我将在接收后挂钩文件中使用
I would use in post-receive hook file:
git --git-dir="$GIT_DIR" --work-tree="$GIT_WORKDIR1" submodule update --init --recursive
但出现以下错误:
remote: fatal: /usr/libexec/git-core/git-submodule cannot be used without a working tree.
我没有解决这个问题.
我应该怎么做才能使其正常工作?
What should I do to make it work?
推荐答案
如果您已重命名git子模块的路径(工作树),则可能会看到此错误.就我而言,我已经更新了.gitmodules
中的路径以匹配新路径,并认为自己很好.但是,当我稍后执行git pull
时,它在旧路径中添加了新文件.这是因为定义模块路径的位置有两个.您还需要按照.git/modules/{modulename}/config
文件中的定义更新工作树".
You may see this error if you've renamed the path (working-tree) of a git submodule. In my case I had updated the path in .gitmodules
to match my new path and thought I was good. But when I did a git pull
later it added new files in the old path. This is because there are two places the module path is defined. You need to also update your "working-tree" as defined in the .git/modules/{modulename}/config
file.
此帖子上也有关于工作树的一些重要细节.
There are some great details about the working-tree on this post as well.
这篇关于GIT错误:致命:没有工作树,无法使用/usr/libexec/git-core/git-submodule的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!