git 子模块 submodule

375 阅读1分钟

git-scm.com/book/zh/v2/…

$ git submodule init
$ git submodule update

git submodule update --init --recursive

.git/config

image.png

image.png .gitmodules

image.png

//如果给 `git clone` 命令传递 `--recurse-submodules` 选项,它就会自动初始化并更新仓库中的每一个子模块, 包括可能存在的嵌套子模块。
$ git clone --recurse-submodules https://github.com/chaconinc/MainProject
git submodule add [-b <branch>] <url> <path>


$ git submodule add
usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
   or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
   or: git submodule [--quiet] init [--] [<path>...]
   or: git submodule [--quiet] deinit [-f|--force] (--all| [--] <path>...)
   or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--] [<path>...]
   or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
   or: git submodule [--quiet] foreach [--recursive] <command>
   or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
   or: git submodule [--quiet] absorbgitdirs [--] [<path>...]