Create ~/main_project/.gitmodules file and add the followings lines to it:
Run the following commands to initialize the submodule:
“git submodule update” command does not checkout to “master” branch. So we need to create master branch and then switch to it as below:
When something changes in sub project
Since sub_project is a submodule in main_project, when something changed in submodule, main projects also needs to be notified(synced) about this change.
Adding a new file to submodule and pushing to sub_project’s repository
Pushing the main_project to remote repository
After we updated sub_project, we need to update main_project too.
After you run “git status” you should see something like this:
Your main projects understands that something has changed inside the sub_project, so it is considered as “modified”. This means that we need to commit and then push to remote git repository as below: