Git Submodule — Make it work

What is Git Submodule

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

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 update

This 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 origin

Reference

Please share this to help others.

Enjoy Git :)

@GoogleDevExpert — #WebTechnologies & @angular | #Principal #Architect at @Naukri | #Entrepreneur | #TechEnthusiast | #Speaker

@GoogleDevExpert — #WebTechnologies & @angular | #Principal #Architect at @Naukri | #Entrepreneur | #TechEnthusiast | #Speaker