The use of Git submodule

Source: Internet
Author: User
Tags using git

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.