Empty Git submodule folder when repo cloned

60,350

OK I found it, needed to add --recursive when cloning the repo.

So the clone command ends up as:

git clone https://github.com/aikiframework/json.git --recursive

Note that if you forgot the --recursive flag you can do (thanks to @Amber):

git submodule update --init
Share:
60,350

Related videos on Youtube

jcubic
Author by

jcubic

My name is Jakub T. Jankiewicz, I'm coding mostly in JavaScript. I love Lisp Macros, jQuery library, ReactJS, CSS3, HTML5, SVG, GNU/Linux, GNU Emacs and Inkscape. Working with JavaScript and R for Roche/Genentech via Astek Poland. my english blog - In Code We Trust my polish blog - Głównie JavaScript (ang. Mostly JavaScript) Usefull Links Other links Yet another links Few of my JavaScript Open Source projects: jQuery Terminal: JavaScript library for Web based Terminal Emulator LIPS - Powerful Scheme based lisp interpreter written in JavaScript sysend.js: Library for sending messages between Windows and Tabs Gaiman Programming Language and Text based Game engine GIT Web Terminal Posts: EchoJS News, EchoJS News (2), HackerNews

Updated on October 13, 2021

Comments

  • jcubic
    jcubic over 2 years

    I have one repo hosted at https://github.com/aikiframework/json . On my local copy, I added a submodule using the command

    git submodule add [email protected]:jcubic/json-rpc.git json-rpc
    

    Then I did a commit and push, and the changes appear on GitHub (I can click on it). But when I clone the repo

    git clone https://github.com/aikiframework/json.git
    

    the submodule folder json-rpc is empty.

    What am I missing here? Did I forget about something? Why is that folder empty?

    • Charlie Parker
      Charlie Parker about 3 years
      if you forgot the --recursive flag in your git clone then you can do git submodule update --init
    • jcubic
      jcubic about 3 years
      @CharlieParker it's in accepted answer first comment.
  • Amber
    Amber almost 12 years
    Yep. You can also fetch submodules after the fact with git submodule update --init, if you already cloned but forgot --recursive.
  • d4Rk
    d4Rk about 11 years
    Just faced the problem that there is a submodule on develop branch, but not yet on the master branch. When you clone the git repo using --recursive it will not find the submodule on the master branch, and you have to fetch it using Ambers comment "git submodule update --init" to get also the subomdule.
  • Noitidart
    Noitidart over 7 years
    If you use git submodule update --init you will have to go to each repo and do git checkout master otherwise you'll get error You are not currently on a branch. on git pull when you try to update it to a newer version.
  • borgr
    borgr over 6 years
    @Noitidart is there a way that doesn't do that? (after cloning the project already)
  • Noitidart
    Noitidart over 6 years
    @borgr i couldn't figure it out
  • Jari Turkia
    Jari Turkia almost 6 years
    @Noitidart Thanks for the update --init hint. That does help when original clone didn't have --recursive in it and simply wanting to pull the missing submodules.
  • Noitidart
    Noitidart almost 6 years
    Thanks for that note @JariTurkia - I didn't know I needed that because I had forgot --recursive.