美文网首页
git 子模块的使用

git 子模块的使用

作者: Biao_349d | 来源:发表于2021-05-07 10:54 被阅读0次
  1. 创建 submoduleA
    创建 submoduleB

  2. 初始化上面两个项目的git

  3. 在 submoduleB 中添加子模块并且关联到submoduleA
    git submodule add https://github.com/chaconinc/submoduleA

运行 git status

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   .gitmodules
    new file:   DbConnector

目录下新增了 .gitmodules文件

  1. 克隆含有子模块的项目
    git clone https://github.com/chaconinc/submoduleB

这时候submoduleB>submoduleA文件夹是空的

初始化更新子模块
git submodule init
git submodule update

第二甚至更多次的时候 更新所有子模块

git submodule update --remote

如果子模块下还有子模块
git submodule update --recursive

  1. 更多配置

设置之后, git status的时候, 可以看到子模块的更新commit
git config status.submodulesummary 1
git status

 git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .gitmodules
        modified:   submoduleA (new commits)

Submodules changed but not updated:

* submoduleA b035a71...c67058d (2):
  > feat: xx

no changes added to commit (use "git add" and/or "git commit -a")

配置更新子模块的分支

git config -f .gitmodules submodules.submoduleA.branch master

.gitmodules

[submodule "submoduleA"]
    path = submoduleA
    url = https://github.com/zgbbiao/submoduleA.git
[submodules "submoduleA"]
    branch = master

相关文章

  • Ansible常用模块

    git模块 简介 此模块用于checkout远程git仓库中的文件 使用要求(在执行模块的主机上) git>=1....

  • gitmodules详解(Git子模块配置)

    git子模块 项目中经常使用别人维护的模块,在git中使用子模块的功能能够大大提高开发效率。 使用子模块后,不必负...

  • git子模块操作

    子模块使用1.添加子模块git submodule add path(git地址) localPath(本地路...

  • git submodule 管理子工程

    git submodule 管理子工程 摘要:当多人共同维护一个项目时,必然需要进行模块化开发,所以使用submo...

  • git Submodule

    git Submodule 是一个很好的多项目使用共同类库的工具。 添加子模块 更新子模块 删除子模块

  • 第四个模块 Git多人项目开发

    第四个模块-GIT远程分支回滚第四个模块 Git基础及分支使用场景 我的角色: 完成自己的功能模块 合并其它成员的...

  • Git - 子模块使用

    https://git-scm.com/book/zh/v2/Git-工具-子模块

  • git子模块的使用

    git子模块的使用 git子模块可以用于项目包含另一个项目的情况,也许是第三方库或被多个项目引用的基础框架。此次学...

  • git 子模块的使用

    git submodule study 添加子模块 git submodule add http://ip:300...

  • git 子模块的使用

    创建 submoduleA创建 submoduleB 初始化上面两个项目的git 在 submoduleB 中...

网友评论

      本文标题:git 子模块的使用

      本文链接:https://www.haomeiwen.com/subject/nfmddltx.html