Add Git Submodules
To reuse code from another repository, you can specify Git™ submodules to include in your project.
To clone an external Git repository as a submodule:
On the Project tab, in the Source Control section, click Submodules.
In the Submodules dialog box, click Add.
In the Add Submodule dialog box, in the Remote box, specify a repository location. Optionally, click Validate.
In the Path box, specify a location for the submodule in your project and click OK. The Submodules dialog box displays the status and details of the submodule.
Check the status message, and click Close to return to your project.
You can use Git submodules to populate a referenced project. For more information, see Organize Projects into Components Using References and Git Submodules and watch How to Organize Large Projects into Components (3 min, 32 sec).
After using Pull on the top-level project, check submodules are up to date by clicking Submodules and then click Update. If any submodule definition have changed, then the update ensures that the submodule folder contains the correct files. Update applies to all child submodules in the submodule hierarchy.
Use Fetch and Merge with Submodules
When you want to manage a submodule, open the Submodules dialog box.
To get the latest version of a submodule, in the Submodules dialog box, click Fetch.
After fetching, you must merge. Check the Status message in the Submodules dialog box for information about your current branch relative to the remote tracking branch in the repository. When you see the message
Behind, you need to merge in changes from the repository to your local branch.
Click Branches and merge in the origin changes to your local branch using the Branches dialog box. See Pull, Fetch, and Merge.
Use Push to Send Changes to the Submodule Repository
If you make changes in your submodule and want to send changes back to the repository:
Perform a local commit in the parent project.
Open the Submodules dialog box and click Push.
If you want other project users to obtain your changes in the submodule when they clone the parent project, make sure the index and head match.
In the Submodules dialog box, check the index and head values. The index points to the head commit at the time you first cloned the submodule, or when you last committed the parent project repository. If the index and head do not match, you must update the index.
To update the index, commit your changes in the parent project, and then click Push in the Submodules dialog box. This action makes the index and head the same.