Git submodule, submodule

Source: Internet
Author: User

Git submodule, submodule

Prerequisites:

1. The project is not highly dependent and relatively simple. It should be less than five (if it is relatively large, use the repo of android)

2. Note that submodule submission must be executed in its directory.

3. Note that git submodule update

4. For cyclic execution, you can use git submodule foreach git submodule update


The main application and use of others' libraries do not need to be maintained by yourself


In short, it is simple, but it cannot be overly dependent. It depends on each seed module to use repo. So many projects on Android still run perfectly.


Start

Create

Git submodule add helloworld. git

Git commit-m "Add submodules helloworld. git"

Collaboration with others

Git clone/path/to/repos/helloworld_parent.gitgit submodule initgit submodule update

Or

Git clone -- recursive/path/to/repos/foo. git

Remove

1. Delete git cache and physical folders

2. Delete the content of. gitmodules (or the entire file) because there are only two sub-modules in this example, you can directly delete the file.

3. Delete the submodule configuration source file of. git/config.

4. Submit changes

Git user's manual for submodule




How to add a directory in a project as git submodule

The submodule method of git does not add actual content to the repository. Instead, it only retains the hash value of the corresponding sub-module through the. gitmodules file. Since the code you really want to use is in a sub-directory, my solution is that you first extract this sub-Directory into a separate warehouse (you can use the git-subtree.sh script ), then add the repository as the submodule (or directly integrate the actual code into your project using the git-subtree.sh so that someone else does not need to update the submodule for cloning ). The disadvantage of this is that the repository of the submodule needs to be updated whenever there is an update in the upstream. In addition: The git-subtree.sh has been merged into git, may not be in PATH, cannot be executed directly, but should be in git installation. Another idea: Create a bundles directory, add the original repository as the submodule, and then make a soft link to the required sub-directories. git can correctly process soft links. This may be a better method, so you do not need to maintain the synchronization with the same game. ----------- What you have done in the sub-module directory is the split operation of the git-subree.sh, this time the warehouse has been completely different from orgin, is equal to re-establish a repository with the subdirectory as the root, objects in this repository are only stored locally and are not included in the repository of origin, so they are not valid at the end.

Git Problems

1. Download a git Repository from github.com: googledrive/dredit. git. The repository name is dredit and enters the repository.
2. initialize a sub-module
3. update this sub-module. -- recursive recursively

To use git in windows, install msysgit, code.google.com/p/msysgit/

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.