In the development process, there are often some common parts of the hope to be extracted into a public library to provide for other projects to use, and the Public Code library version management is a troublesome thing. Today, the git git submodule command was accidentally discovered, and the previous problem was solved.
Add to
To add submodule to the current project, the command is as follows:
Git submodule Add warehouse address path
Where the warehouse address refers to the sub-module warehouse address, the path refers to the sub-module is placed under the current project path.
Note: The path cannot be in/end (will cause the modification not to take effect), cannot be the existing project already has the directory (cannot shun the Clone)
When the command executes, a file named ". Gitmodules" is generated under the current project root path, which records the submodule information. Once added, add the folder that contains the submodule to the project.
Delete
Submodule's removal is a little tricky: first, remove the configuration information in the ". Gitmodules" file. Then, execute the "git rm–cached" command to remove the file that contains the submodule from Git.
Download the project with Submodule
When using Git clone down the project with Submodule, the initial time, the Submodule content is not automatically downloaded, at this time, only need to execute the following command:
git submodule update--init--recursive
The sub-module content can be downloaded after the project will not be missing the corresponding files
The use of Git submodule