Git Submodules. Pulling into a new clone of a super project

OK So I thought I was licking it ... but now ....

I have a project that includes one small library from GitHub as a submodule. In the original version of this superproject, the submodule works as expected.

However, I just cloned the super project, did what I thought should: "git subodule init", got the submodule directory, but it is empty.

If I try to do

git submodule update 

I get

 fatal: Needed a single revision Unable to find current revision in submodule path 'external_libraries/BEACHhtml' 

If i try

 git submodule foreach git pull 

I get

 Entering 'external_libraries/BEACHhtml' fatal: Where do you want to fetch from today? Stopping at 'external_libraries/BEACHhtml'; script returned non-zero status. 

In my .git / config, I have this:

 [submodule "external_libraries/BEACHhtml"] url = git@github.com:interstar/BEACHhtml.git 

In my .gitmodules, I have this:

 [submodule "external_libraries/BEACHhtml"] path = external_libraries/BEACHhtml url = git@github.com:interstar/BEACHhtml.git 

Has anyone realized what is missing?

+82
git git-submodules
Sep 30 2018-11-11T00:
source share
7 answers

It seems that now (in 2019) installing the latest version of the GIT client can solve the problem according to the comments below. This should be the best solution at the moment.




I have the same problem as you. This is a bug in git: http://lists-archives.com/git/785138-git-submodule-update-is-not-fail-safe.html

In short, for your problem try:

 # rm -rf external_libraries/BEACHhtml # git submodule update 

There seems to be something wrong with the previous extraction folder, delete it and update again to solve the problem.

+178
Dec 20 2018-11-11T00:
source share

I had this problem (a broken network, so I got a deferred submodule check like this) and I solved it by doing this script (called it git-submodule-fix so that I could run it as git submodule-fix )

 #!/bin/bash for arg do echo $arg find . -name "`basename $arg`" | grep "$arg\$" | xargs rm -fr done 

If you get this, i.e. from git submodule update

 fatal: Needed a single revision Unable to find current revision in submodule path 'some/submodule/path' 

do

 git submodule-fix some/submodule/path git submodule update 
+4
Jul 04 '13 at
source share

Solved by removing 2 directories and the refetching submodule:

  • Go to external_libraries/BEACHhtml and look at the .git file. It should be something like gitdir: ../../.git/modules/external_libraries/BEACHhtml
  • Remove the external_libraries/BEACHhtml and .git/modules/external_libraries/BEACHhtml .

Now git submodule update works without errors.

+3
Jul 26 '17 at 10:57
source share

use the diff tool to compare the original clone that works and this one. Also what git submodule . Make sure you point to one branch in each repo before you do.

I suspect that you switched to a branch or an earlier version where the submodule was not defined.

hope this helps

0
Sep 30 2018-11-11T00:
source share

I had the same problem with the submodule in the project. When I tried to clone the submodule separately, it worked well.

I tried all the answers above, but to no avail (git updating the submodule, ..., deleting the submodule folders, ...).

The problem disappeared after updating git (from Git -1.7.11-preview20120710) to the latest version (to Git -1.8.1.2-preview20130201) at that time. It’s strange that my colleagues had an even older version, they worked without any problems, but they were on a Mac. I'm on Win7 64bit.

0
Mar 04 '13 at 9:55 on
source share

If you read in 2019 or later, just upgrade your git client. Worked for me.

0
Jul 17 '19 at 20:44 on
source share

I am on Window7. run 'rm -rf src / sizzle', maybe ok!

E: \ GitHub \ fork \ jquery> rm -rf src / sizzle
E: \ GitHub \ fork \ jquery> git update submodule
Submodule path 'src / sizzle': issued by '19c7b3440385c9f628a7bc1c5769f6946fcc6887'

E: \ GitHub \ fork \ jquery> grunt.cmd

...
Saved as: master

Done, no errors.

-5
Jan 18 '13 at 9:12
source share



All Articles