Sometimes, we need to extract some common parts into a common library, which can be used for other projects, and the version management of public code libraries is cumbersome. We can use submodule in git to do this.
1. Add
Add Submodule to the current project, the command format is: Git submodule add warehouse address path
After the addition is complete, a file named ". Gitmodules" is generated under the current project path, which records the submodule information and adds the folder where the submodule resides to the project.
2. Delete
To remove Submodule, we first delete the appropriate configuration information in the. gitmodules file, and then execute the git rm-cached command to remove the file from Git from your submodule.
3. Update
We can update submodules using git submodule update.
4 . Note
When using Git clone down the project with Submodule, the initial time, submodule content will not be downloaded automatically, we do git submodule update--init--recursive.
Sinsing analysis of submodule in Git