Git 克隆包含子模块的仓库

date
Jan 11, 2023
slug
git-clone-submodule
status
Published
tags
Git
summary
当一个 git 项目包含子模块(submodule) 时,直接克隆下来的子模块目录里面是空的。
type
Post

情况一:项目已克隆到本地

  1. 初始化本地子模块配置文件
git submodule init
  1. 更新子模块内容
git submodule update

情况二:项目未克隆到本地

  1. 在执行 git clone 加上 --recursive 参数。它会自动初始化并更新每一个子模块。
git clone --recursive https://github.com/therainisme/example.git

© therainisme 2025