Git uses sub-modules to reference external projects

Source: Internet
Author: User

Git uses sub-modules to reference external projects
Introduction to Git submodule

This is often the case. When you work on a project, you need to use another project. It may be a third-party library or a library that you develop independently and use in multiple parent projects. In this scenario, the next common problem arises: You want to process two projects separately, but you need to use another one.
The sub-module allows you to treat a Git repository as a subdirectory of another Git repository. This allows you to clone another repository to your project and keep your submission independent.

Add a sub-module for Git sub-module usage

First, you need to clone the external repository to your subdirectory.
Assume that you want to add the pacman project to your blog project.git submodule addAdd an external project as a sub-module:

12 Cd bloggit submodule add https://gitcafe.com/aceking/pacman.git themes/pacman

Now you have a pacan project in the themes/pacman subdirectory of the project. You can go to the subdirectory to make changes, add your own remote writable warehouse to push your changes, pull and merge the changes from the original warehouse, and so on.

. Gitmodules file: This is a configuration file that saves the project URL and the local subdirectory you pulled.

Clone a project with a tape Module

Clone the project that you just created the sub-module. You will get the directory containing the subitem, but there is no file in it: the pacman directory exists, but it is empty.
You must run the following two commands:git submodule initTo initialize your local configuration file,git submodule updateTo pull all data from that project and check out the appropriate submissions listed in your upper-level project.

123 Cd bloggit submodule init themes/pacamangit submodule update

Now your pacman sub-directory is in the exact state you submitted previously.

 

Fedora downloads Git through Http Proxy

Install Git on Ubuntu Server

Create a Git repository on the server (Ubuntu)

Git simple tutorial in Linux (taking Android as an example)

Git authoritative guide PDF

Git 2-minute Guide

Git details: click here
Git: click here

This article permanently updates the link address:

Related Article

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.