Submodule not showing up in repo

18,104

Solution 1

I found a solution to this for anyone else who may stumble into this thread. After messing around with updating I ended up adding the submodule again with git submodule add --force <url> <path>. The --force option was necessary because git was seeing another module with the same name. Somehow this link was broken and not updating. After this step running git submodule update, the directory was populated and a link appeared in the github page signifying the change.

I found this information in the following link:

Link

Solution 2

Before using submodules you have to init then and only aftr that you can update them.

git submodule add <url> <name>

Then you .git/config should contain the following entry:

[submodule "name"]
    path = extension
    url = <url>

Now you have submodules in a project, at this point you have to init and "install" it under the main repository (it should clone the submodule content to the defined path).

git submodule init
git submodule update

Now you all set to go.


When I commit or try to do anything to update the repo I am not seeing anything which indicates the submodule is loading in the correct place.

submodule is a standalone repository so any changes made inside the submodule folder are not visible outside of this folder and vice versa.

Any changes made under the submodule have to commited seperatly inside the submodule folder.

Share:
18,104
eignhpants
Author by

eignhpants

Updated on July 31, 2022

Comments

  • eignhpants
    eignhpants over 1 year

    I am building some custom rpm packages, and am trying to include the source of another project as a submodule to build from. During my first run I added the package and when I looked at the Github page I could see the icon showing the linked submodule, but it was in the wrong place.

    I did some changes to place the submodule where I need it (in a /SOURCES folder) but when I commit or try to do anything to update the repo I am not seeing anything which indicates the submodule is loading in the correct place.
    I also don't see any changes when using submodule update or any other related command.

    Should I just erase the .gitmodules file and start over? I am worried that will have unforeseen consequences. Is there any command to tell git to check the .gitmodules file and take action accordingly?

    Thanks for any help.

  • eignhpants
    eignhpants over 8 years
    So I actually have a few entries in my .git/config under submodules, maybe from when I was trying different things. They all look like this: [submodule "rpmbuild/SOURCES/collectd"] url = git://git.verplant.org/collectd.git and there are three entries. So I thought if I just did submodule update it would work, since they are already initialized. However that doesn't seem to have any effect, and git diff has no output even though according to the git docs there should be some output.
  • CodeWizard
    CodeWizard over 8 years
    Remove all the duplicates, go into the submodule folder and run git fetch --all --prune inside the submodule folder. It should update the submodule
  • eignhpants
    eignhpants over 8 years
    This didn't work either but I did find a solution which I will post as an answer. Thanks for your help.
  • josh.chavanne
    josh.chavanne almost 7 years
    This was the only thing that worked for me on my production machine, I have no idea why this was down-voted. The submodule on my dev box was fine but upon pulling down my containing repo on my production box I had to counter-intuitively do the submodule init per CodeWizards' comment. Thanks!