How effectively delete and add a git submodule
Git Submodules are the concept related to modularity. One git repository can be added to another as a submodule and maintained separately. Instead of being tightly coupled, it is loosely coupled and is easy to maintain.
Suppose you are working with software A which depends on library A, instead of copy-pasting the library A over and over again when a new version of the library is released what we can do is use submodule to make this process DRY and elegant.
Delete
git submodule deinit <path_to_submodule>
git rm <path_to_submodule>
git commit -m "Removed submodule "
rm -rf .git/modules/<path_to_submodule>
Add
git submodule add https://github.com/xiaoshan1994/hugo-tranquilpeak-theme.git themes/hugo-tranquilpeak-theme
If you try to add the submodule using git submodule add
, you’ll need to delete the theme from themes and push. Otherwise, it’ll think it’s still in the index.