Recursively cloning a git repo doesn't pull submodules
I'd like to clone a git repo [1], which has a submodule defined in .gitmodules
:
[submodule "PointInCircle"]
path = PointInCircle
url = https://github.com/midas-journal/midas-journal-843
Following these questions [2-4], I tried:
$ git clone --recursive https://github.com/midas-journal/midas-journal-851
If I understand submodule
s correctly, which I obviously don't, there should be a directory inside midas-journal-851
called PointInCircle
with the second repo cloned into it. However, no PointInCircle
directory is created and as far as I can tell the code isn't cloned anywhere. For good measure, I also tried...
$ git submodule init
$ git submodule update
...as well as...
$ git submodule update --init --recursive
...and...
$ git submodule foreach --recursive git submodule update --init
...in the cloned directory. Each command runs without printing anything to the console, and I don't see any changes in the directory.
Any ideas what I'm doing wrong?
[1] https://github.com/midas-journal/midas-journal-851
[2] Cloning a git repo with all submodules
[3] How to `git clone` including submodules?
[4] 'git submodule update --init --recursive' VS 'git submodule foreach --recursive git submodule update --init'
Any ideas what I'm doing wrong?
You're not doing anything wrong. That repository's submodule is only partially configured.
Submodules are defined by two things:
Submodules are composed from a so-called gitlink
tree entry in the main repository that refers to a particular commit object within the inner repository that is completely separate. A record in the .gitmodules
... file at the root of the source tree assigns a logical name to the submodule and describes the default URL the submodule shall be cloned from.
This repository contains a .gitmodules
file, but no gitlink
objects.
GitHub displays proper submodules with a grey folder icon, which is absent from this repository:
Since the faulty .gitmodules
file only contains a single entry, in your case I recommend
deleting the .gitmodules
file,
git rm .gitmodules
adding the submodule properly,
git submodule add https://github.com/midas-journal/midas-journal-843 PointInCircle
and committing.
git commit -m "Fix PointInCircle submodule"
The output from git commit
should show PointInCircle
being added with mode 160000
(indicating a gitlink
), and your repository should now be properly configured. Use git submodule status
to be sure:
$ git submodule status
9bc2651367f8cc5f47ac5f6c708db2f9a71d8fd8 PointInCircle (heads/master)
You might want to open a pull request to the parent repository with your fix, but since it only contains a single commit from three years ago I suspect that it is abandoned.
链接地址: http://www.djcxy.com/p/92416.html上一篇: GIT获取多个版本库
下一篇: 递归克隆git仓库不会拉动子模块