Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git submodule is returning blank?

Tags:

I'm trying to use git submodule update and it's not returning anything, nor does any of the git submodule commands, and I have checked the .gitmodules file and it is correct?

I have no idea if git can be debugged or what, and it's really annoying.

There's no errors or anything, even when using 2>&1 on the end which is really worrying.

like image 484
Joe Simpson Avatar asked Jul 10 '12 19:07

Joe Simpson


People also ask

How do you fix a dirty submodule?

You can fix it by: either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .

How to initialize submodules in git?

If you already cloned the project and forgot --recurse-submodules , you can combine the git submodule init and git submodule update steps by running git submodule update --init . To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive .

Why is submodule detached head?

By default your submodule repository is in a state called 'detached HEAD'. This means that the checked-out commit -- which is the one that the super-project (core) needs -- is not associated with a local branch name.

Does git submodule automatically update?

A git submodule is a record within a host git repository that points to a specific commit in another external repository. Submodules are very static and only track specific commits. Submodules do not track git refs or branches and are not automatically updated when the host repository is updated.


2 Answers

It could be a late answer but in case someone needs it:

Just delete you blank submodule directory and run again

git submodule add <https/ssh git link to your submodule>

like image 21
qwebek Avatar answered Oct 26 '22 02:10

qwebek


Remove any submodule entries from your .git/config. git rm --cached path/to/submodule to remove it from the tree. Make sure your working directory is clean. Now you can init the submodules:

git submodule init 

All this does is populate your config with the urls that are in the .gitmodules file. Now you can populate the submodules:

git submodule update

if your submodules have nested submodules, add the recursive option:

git submodule update --recursive

Init and update are separate for a good reason. You may want to have an alternate repository to store changes to you submodule.

like image 135
Adam Dymitruk Avatar answered Oct 26 '22 03:10

Adam Dymitruk