Recursively cloning a git repository does not pull submodules
I would like to clone a git repository <1> that 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 correctly submodule
, which I obviously can't see, there should be a directory inside midas-journal-851
called PointInCircle
, with the second repo cloned. However, no directory is created PointInCircle
and as far as I can tell the code is not cloned anywhere. For good measure, I've also tried ...
$ git submodule init $ git submodule update
... and...
$ 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 directory changes.
Any ideas what I am doing wrong?
[1] https://github.com/midas-journal/midas-journal-851
[2] Cloning a git repository with all submodules
[3] How to clone git including submodules?
[4] 'git submodule update --init --recursive' VS 'git subodule foreach --recursive git submodule update --init'
source to share
Any ideas what I am doing wrong?
You are not doing anything wrong. This repository submodule is only partially configured.
Submodules are defined by two things :
Submodules consist of what is called a tree entry
gitlink
in the main repository, which refers to a specific commit object within the internal repository that is completely split. The file entry.gitmodules
... at the root of the source tree assigns a logical name to the submodule and describes the default URL from which the submodule should be cloned.
This repository contains the file .gitmodules
, but not gitlink
.
GitHub displays the correct submodules with a gray folder icon missing from this repository:
Since the faulty .gitmodules
file only contains one entry, in your case I recommend
-
deleting a file
.gitmodules
,git rm .gitmodules
-
adding the submodule correctly,
git submodule add https://github.com/midas-journal/midas-journal-843 PointInCircle
-
and committing.
git commit -m "Fix PointInCircle submodule"
The output git commit
should be added PointInCircle
with a mode 160000
(indicating gitlink
) and your repository should now be configured correctly. Use git submodule status
to make 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 one commit from three years ago, I suspect it has been abandoned.
source to share