Git submodule tips

git submodule is powerful to control repositories and easy to use, but how to add it to project?

Problem

For example, my hexo project want to add theme hexo-theme-melody with Netlify, somehow you don’t put all files in project, you need update it, use submodule to do it.

...
7:01:14 PM: Error checking out submodules: fatal: No url found for submodule path 'themes/melody' in .gitmodules
7:01:14 PM: Failing build: Failed to prepare repo
7:01:14 PM: failed during stage 'preparing repo': Error checking out submodules: fatal: No url found for submodule path 'themes/melody' in .gitmodules
...

Set

Creating .gitmodules file in your project dictionary, next, you should add belong:

[submodule "themes/melody"]
path = themes/melody
url = https://github.com/Molunerfinn/hexo-theme-melody.git

Update

$ git submodule update –init

If you got any erros, you should remove cache.

$ git rm –cached probberechts/hexo-theme-cactus

git-scm
solution found 1