Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Git and Maven create and use submodule projects

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "how to create and use sub-module projects for Git and Maven". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to create and use sub-module projects with Git and Maven.

Create a sub-module project

Open Git Bash, create an empty directory and enter:

$mkdir erp-submodules$ cd erp-submodules/

Initialize the current directory as a Git repository

$git init

Add all submodules (you can enter multiple lines of commands at a time to see if the last line of commands is executed):

$git submodule-b master add http://IP/auto-erp/purchase.gitgit submodule-b master add http://IP/auto-erp/checkup.gitgit submodule-b master add http://IP/auto-erp/task.gitgit submodule-b master add http://IP/auto-erp/sale.gitCloning into 'purchase'...remote: Counting objects: 5151, done.remote: Compressing objects: 100% (86 Plus 86), done.remote: Total 5151 (delta 49) Reused 108( delta 30) Receiving objects: 100% (5151 MiB), 1.12 MiB | 0 bytes/s, done.Resolving deltas: 100% (2269 Universe 2269), done.Checking connectivity... Done.warning: LF will be replaced by CRLF in .gitmodules.The file will have its original line endings in your working directory.

Wait for all project downloads to complete.

At this point, all the subprojects are created, and the submodule configuration is used to facilitate the import of all projects in MAVEN.

Add pom.xml under the current project as follows:

4.0.0 com.github.abel533 erp-modules 1.0.0-SNAPSHOT pom purchase barch checkup task sale packing logistics

At this point, the project is complete, commit the local changes and upload to the git server.

# add all $git add-all# submit $git commit-m 'first commit'# add remote warehouse address $git remote add origin created warehouse address # push $git push origin master

Check out imported project

After following the above steps, you can use it locally, but if other members want to download it, you need to check it out.

In the directory you want to check out, open git bash and enter the following command to check out the project:

$git clone-- recursive warehouse address # is part of the output log Cloning into 'erp-modules'...remote: Counting objects: 6, done.remote: Compressing objects: 100% (6 delta 6), done.remote: Total 6 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (6 delta 6), done.Checking connectivity... Done.Submodule 'ERPcrm' (http://IP/auto-erp/ERPcrm.git) registered for path' ERPcrm'Submodule 'accountNew' (http://IP/auto-erp/accountNew.git) registered for path' accountNew'Submodule 'barch' (http://IP/auto-erp/barch.git) registered for path' barch'Submodule 'checkup') (http://IP/auto-erp/checkup.git) registered for path' checkup'Submodule 'contract' (http://IP/auto-) Erp/contract.git) registered for path 'contract'Cloning into' ERPcrm'...remote: Counting objects: 1651 Done.remote: Compressing objects: 100% (274bytes/s 274), done.remote: Total 1651 (delta 139), reused 447 (delta 70) Receiving objects: 100% (1651 bytes/s), 265.91 KiB | 0 bytes/s, done.Resolving deltas: 100% (494 bytes/s), done.Checking connectivity... Done.Submodule path 'ERPcrm': checked out' 26686570bc1f22627f717830599ac77248014b87'Cloning into 'accountNew'...remote: Counting objects: 1850, done.remote: Compressing objects: 100% (689 delta), done.otal 1850 (delta 866), reused 1624 (delta 664) Receiving objects: 100% (1850 KiB), 496.70 KiB | 0 bytes/s, done.Resolving deltas: 100% (866 KiB), done.Checking connectivity... Done.

At this point, all the sub-modules are downloaded automatically, but none of the sub-modules select branches, and if you do not select branches, it will cause confusion in the project, so switch branches and update.

# enter the directory $cd erp-modules/# under clone and execute the following command git submodule foreach $git submodule foreach git checkout master & & git pull origin master

All submodules are switched to the master branch and updated. You can import the project into IDE.

In subsequent use, always pay attention to the branches of the sub-module to prevent accidental errors.

Using git submodule foreach, it is very convenient to execute commands on sub-modules in batches.

At this point, I believe you have a deeper understanding of "how to create and use sub-module projects for Git and Maven". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report