git submodule

Initialize, update or inspect submodules

A submodule allows you to keep another Git repository in a subdirectory of your repository. The other repository has its own history, which does not interfere with the history of the current repository. This can be used to have external dependencies such as third party libraries for example.

I came across this as I was trying to deploy my Hugo powered website on Github Pages.

The public directory from Hugo website is linked to my repository using submodules.

From Hugo’s documentation, this is how you add a submodule: git submodule add -b master<username>/<username> public

If you run into an error which says already exists in the index, try doing this git rm -r --cached <folder> and then type this git submodule add -b master<username>/<username> public

Worked for me! :)

Published by in May, TIL, Technical and 2017 and tagged git using 132 words.