了解Git Submodules 有2个概念:主项目、submodule(子模块)。这两者各自都是完整的 Git 仓库。 如何让一个Git仓库变为另一个Git仓库的 submodule 创建Git仓库A。 创建Git仓库B。 在Git仓库A中,通过git submodule add ...(仓库B的地址,即git clone时后面那串东西),可以把仓库B当作仓库A的sub
Git Submodules 是 Git 提供的一个强大功能,允许你在一个 Git 仓库(称为父仓库)中嵌套另一个 Git 仓库(称为子模块仓库)。本文将详细介绍 Git Submodules 的概念、使用场景以及常用命令的使用。 一、Git Submodules 概念 Git Submodules 允许你在一个 Git 仓库中引用另一个 Git 仓库,作为其子目录。这个子目...
初始化子模块:git submodule init 更新子模块:git submodule update 递归克隆整个项目submodule:git clone https://github.com/demo.git assets --recursive 递归更新整个项目submodule:git submodule foreach git pull 删除子模块:git rm --cached subModulesA rm -rf subModulesA --recursive表示递归地克隆git_pare...
Let’s start by adding an existing Git repository as a submodule of the repository that we’re working on. To add a new submodule you use thegit submodule addcommand with the URL of the project you would like to start tracking. In this example, we’ll add a library called “DbConnector...
Make changes to submodule Push changes to remote Reference 我们经常需要在项目A中使用其他项目B,项目B可能是第三方的库或者被多个项目共享的子项目。Git提供submodules来解决这个问题,通过在项目A中保留项目B的目录,这样就可以在项目A中clone项目B并保持两个项目的commit独立。 Add submodules 下面命令将在项目中添...
使用Git Submodules机制,可以将一个Git仓库作为另一个Git仓库的子目录使用。 以下是使用Git Submodules的详细步骤: 在主仓库中添加子模块 git submodule add https://github.com/user/repo 这将从给定的URL创建一个子模块,并将其添加到主仓库中。 指定分支 ...
关于子模块的更多信息,见gitsubmodules[7]。 命令 没有参数,显示现有子模块的状态。 有几个子命令可用于对子模块进行操作。 add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--ref-format <format>] [--depth <depth>] [--] <repository> [<path>] ...
拉取包含submodule的仓库 方式一 如果给git clone命令传递--recurse-submodules选项,它就会自动初始化并更新仓库中的每一个子模块,包括可能存在的嵌套子模块。 git clone <repo> [<dir>] --recursive 示例: git clone git@github.com:ghostxbh/uzykj-docs.git --recursive ...
了解Git Submodules 有2个概念:主项目、submodule(子模块)。这两者各自都是完整的 Git 仓库。 如何让一个Git仓库变为另一个Git仓库的 submodule 创建Git仓库A。 创建Git仓库B。 在Git仓库A中,通过git submodule add ...(仓库B的地址,即git clone时后面那串东西),可以把仓库B当作仓库A的su...
至于.git/config,仍会记录 submodule 信息,但是本地使用也没发现有什么影响,如果重新从服务器克隆则 .git/config 中不会有s ubmodule 信息。 git rm moduleA git status git commit -m "remove submodule" git push origin master 4. git submodule 终端更新问题 git submodule update出现此问题,是因为终端用的...