git-submodule

Submodule

Add Submodule

1
git submodule add <repository> <path>

Example:

1
git submodule add https://github.com/probberechts/hexo-theme-cactus.git themes/cactus

Clone repository with submodule

如果是 repository 早已有 submodule 的情況下,clone 下來的 submodule 正常情況下會是空的

1
git clone https://github.com/Chengxufeng1994/hexo-site

需要下以下兩個指令:

  1. git submodule init
  2. git submodule update

也可以透過 flag 同時初始化和下載:

  1. git submodule update --init --recursive

Clone repository with submodule (init/update)

1
git clone --recurse-submodules https://github.com/Chengxufeng1994/hexo-site

Remove Submodule

1
git rm <submodule_name>