git在子模块中时找不到索引(“索引文件打开失败:不是目录") [英] git failing to find the index when in submodule ("index file open failed: not a directory")
问题描述
在新的git仓库中,添加子模块并将其更改为子模块目录后,大多数git命令在子模块中运行时失败,并显示以下错误:
On a fresh git repo, after adding a submodule and changing to the submodule directory most git commands fail when run within the submodule with the error:
fatal: index file open failed: Not a directory
用于重现此问题的全套命令:
The full set of commands to reproduce the issue:
> git init .
Initialized empty Git repository in /Users/drh/code/personal/Experiments/git-test/.git/
> git status
On branch master
Initial commit
nothing to commit (create/copy files and use "git add" to track)
> git submodule add git@github.com:mitsuhiko/flask.git thirdparty/flask
Cloning into 'thirdparty/flask'...
remote: Reusing existing pack: 9959, done.
remote: Total 9959 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (9959/9959), 5.17 MiB | 1.11 MiB/s, done.
Resolving deltas: 100% (5617/5617), done.
Checking connectivity... done.
> cd thirdparty/flask
> git status
fatal: index file open failed: Not a directory
> cat .git
gitdir: ../../.git/modules/thirdparty/flask
在小牛上运行的
git版本1.8.5.2
git version 1.8.5.2 running on Mavericks
推荐答案
那是因为父仓库中还没有提交(表示没有HEAD,并且没有git子模块测试涵盖了这种情况.
That is because there isn't a commit yet in the parent repo (meaning no HEAD, and no master
branch).
As you have detected, the GIT_DIR
for the parent repo might be set too late for the submodule to use.
That would be a good bug to report if none of the git submodule tests cover that scenario.
或者,作为 OP user3184153
我认为其他一些应用程序(我怀疑是 I think that some other application (I suspecting 这篇关于git在子模块中时找不到索引(“索引文件打开失败:不是目录")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!virtualenv
,尽管无法复制)正在设置GIT_DIR
.
virtualenv
, though can't reproduce) was setting GIT_DIR
.