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

Solved by deleting 2 directories and refetching submodule:

  1. Go to external_libraries/BEACHhtml and look into .git file. It's content should be something like gitdir: ../../.git/modules/external_libraries/BEACHhtml
  2. Delete both external_libraries/BEACHhtml and .git/modules/external_libraries/BEACHhtml directories.

From now on git submodule update runs without errors.


I had this problem (flaky network so I got dropped submodule checkout like this) and I solved it by making this script (named it git-submodule-fix so 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 a 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

It seems that now (in 2019) installing latest GIT client could solve the problem according to comments below. This should be the best solution for now.


I have the same problem as you. This is a bug in git: http://git.661346.n2.nabble.com/BUG-git-submodule-update-is-not-fail-safe-td7574168.html

In short, for your problem, try:

# rm -rf external_libraries/BEACHhtml
# git submodule update

It seems there is something wrong with the previous checkout folder, remove it, and update again solves the problem.