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

OK. So I thought I had this licked … but now ….

I have a project which includes one small library from GitHub as a submodule. In the original version of that super-project the submodule is working as expected.

  • GitHub: How to do code review on new file with more than 1500 lines
  • Commit on Pull Request of Remote Fork
  • Tracking 3rd party code with Git
  • How do you undo a hard reset in Git Gui or Gitk on Windows?
  • First commit Android Studio Project — What should leave out?
  • git - Is it possible to exclude file from `git push`, but keep them in the local repository?
  • However, I just cloned the superproject, did what I thought I should : “git submodule init”, got the directory of the submodule to appear, but it’s empty.

    If I now 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
    

    Anyone got an idea what’s missing?

  • What are the differences between git cherry-pick and git show | patch -p1?
  • Libcurl.dll error with Git Push even after deleting Libcurl.dll
  • Do I need to perform a commit after a rebase?
  • ways to improve git status performance
  • Why does git commit --amend change the hash even if I don't make any changes?
  • Git from the command line doesn't work, but using a git client (like SmartGit) does
  • 6 Solutions collect form web for “Git Submodules. Pulling into a new clone of the super-project”

    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
    

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

    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
    

    use a diff tool to compare the original clone that’s working and this one. Also, what does git submodule output. Ensure you are pointing to the same branch in each repo before you do.

    I’m suspecting that you’ve switched to a branch or older revision where the submodule was not defined.

    hope this helps

    I had the same issue with a submodule on a project. When I tried to clone the submodule separately it worked well.

    I’ve tried all of the answers above, but without success (git submodule update, …, removing the submodule folders, …).

    The issue disappeared after update of git (from Git-1.7.11-preview20120710) to latest version (to Git-1.8.1.2-preview20130201) at the time. Strangely my colleagues had even older version, worked without any issues, but they were on Mac. I’m on Win7 64bit.

    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 am on Window7.
    run ‘rm -rf src/sizzle’, can ok!

    E:\GitHub\fork\jquery>rm -rf src/sizzle
    E:\GitHub\fork\jquery>git submodule update
    Submodule path ‘src/sizzle’: checked out ’19c7b3440385c9f628a7bc1c5769f6946fcc6887′

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


    Saved as: master

    Done, without errors.

    Git Baby is a git and github fan, let's start git clone.