Git Submodule — Make it work
Aug 23, 2017 · 2 min read

What is Git Submodule
We often require another plugin or library to be included into our projects to achieve faster development. The common way to do the same in using package manager like NPM, PIP, Composer or Bower depending on the chosen language or framework.
Git Submodule help you to treat your library or plugin as a separate project and can be pull, merge or checkout independently from your project.
Setup
To set-up Git Submodule you need to create .gitmodules file in your root directory.
Format of .gitmodules file
[submodule "<submodule_name>"]
path = <path_for_submodule>
url = <repo_url>
branch = <submodule_branch>[submodule "app/lib/mysql"]
path = app/lib/mysql
url = https://github.com/ashokvishwakarma/phpmysql
branch = master
Run following commands to make it work.
git submodule init
git submodule updateThis will add the reference to your .git/config file.
Push the changes to let git know about your submodules
git add . // add all changes to commit
git commit -m "<your_commit_message>" // commit the added files
git push origin <your_branch_name> // push the changes to originReference
To read more about Git Submodules
Please share this to help others.
Enjoy Git :)
