Search code examples
gitgit-submodulesgit-pushgit-clone

Git push submodule on server, pull empty directory


Hi I am pushing my changes using git push origin production on to server #1. When I git clone origin production on server #2, I get all my files except the sub-module. The sub-module is empty with no .git file. I was wondering why this is, and how can I get the files to either #1)git push all files to server (this is a third party library) instead of a pointer or #2)be able to git clone that empty folder.

Server #1:
Root
   -module/
       test/   <--- third party library
          some files

Server #2:
Root
    -module/
        test/  <--- empty

Solution

  • So I have learned more about sub-modules. What ended up happening was I git push origin production, but with sub-modules, they don't push the code! Rather, it pushes a link, the link is a pointer to the third party's repo. Here is my set-up:

    root/ .gitmodules

    Server #1: In here I had:

    [submodule "modules/test"]     <- declaration of submodule
    path = modules/test            <- directory 
    url = https://git.drupal.org/project/webform.git   <-url
    

    Server #2:

    When you get pull, you are just pulling the pointer of this sub-module. You have to call git sub-module init to initialize it. Then git sub-module update which will call the file and clone the directory from the URL you specified in the .gitmodule file.