Use git submodule in sourcetree

Source: Internet
Author: User
Tags sourcetree

During the development process, our project may reference the code generation in other versions. For example, the company has already been tired of using a set of common functions, it is used by multiple targets. Naturally, public correspondence files cannot be directly stored in our development environment, which is not only redundant, it also increases the degree of attention of the hacker. It is no doubt that he is seeking for trouble.

At this time, we can use the submodule feature in git to manage our subtemplates. Here we use the GUI sourcetree (Which of the following is just getting started with ST ), enter the text below ......

 

1. zookeeper jobs

First, we will create two repository records, namely smmain and smliba, and push them to git server (ex: GitHub, Bitbucket... And so on.

Bitbucket

Smmain: https://bitbucket.org/youngce/smmain

Smlaba: https://bitbucket.org/youngce/smliba

 

2. Add submodule

Use git submodule add command in {path}/smmain to add submodule

 

git submodule add https://[email protected]/youngce/smliba.git libs/smlibA

Libs/smliba: Clone the sub-module worker to the {path}/smmain/libs/smliba path. The success is as follows,

One more libs resource can be found in the smmain resource, and uncommitted changes and submodules appear in the St.


Next, commit and push again.

In fact, we can see from the contents of the above libs/smliba case that the repository in smmain is just to remember the commit ID of the subproject.

 

3. submodule update

When an smliba update occurs, how does one update smmain ??

First, update smliba,

 

Click the smmain tag, and then click submodules.

 

At this time, a new tag named smliba will be created. This smliba refers to the smliba under smmain, and then it will be updated by pressing pull.

 

Return to smmain and a new uncommitted will appear. The subproject commit in libs/smliba has been changed to the latest commit ID.

Finally, do not forget to complete the commit + push operation.

 

4. submodule Modification

During the development process, some bugs for the subprogram may be solved or new functions may be added. How can we make such changes and update them to the repository of the subprogram ??

Here, the smliba will be modified in smmain, and then pushed to the real smliba repository.

 

Modify liba.txt directly in the smmainconsumer library !! After the modification, you will find that no uncommitted exists in smmain in St,

Where is the modification of zookeeper going ?? Start the smliba of the submodule !! In fact, you can imagine that the submodule exists in

Repository (submodule) in git repository. Git repository only records the current repository (submodule ).

The commit ID, and the repository (submodule) manages and modifies it by itself.

 

Then commit + push. Don't take it as this is the end. We have to confirm whether the smmain subproject commit has been modified. Otherwise

Our submodule was not modified next time in pull !!

Finally, commit + push !!

Use git submodule in sourcetree

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.