-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathadd_gitmodules.sh
executable file
·61 lines (54 loc) · 2.12 KB
/
add_gitmodules.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#/bin/bash
#
#
git submodule add https://github.com/chensongpoixs/caudio_video.git audio_video_example
git submodule add https://github.com/chensongpoixs/cvideo_codec.git video_codec
#
git submodule add https://github.com/chensongpoixs/cjpeg_encode_decoder.git jpeg_encode_decoder
git submodule add https://[email protected]/chensongpoixs/cd3d10_d3d11_d3d12_dxgi_opengl.git Server/cd3d10_d3d11_d3d12_dxgi_opengl
# 清除缓存
git rm --cached jpeg_encode_decoder
#添加子模块
# 进入主项目
cd workspace
# 给主项目添加子项目,指定子模块克隆到本地src/template文件夹
git submodule add [email protected]:XXX/research-study.git src/template
# 添加子模块后运行
git status # 可以看到目录增加两个文件
# 1. .gitmodules文件(主要用于保存子模块信息)
# 2. src/template文件夹(主要用于存放子模块最新一次commit id)
# 将这两个文件提交到主项目远程
git add .
git commit -m 'add submodule'
git push origin dev
#克隆包含子模块的项目
# 获取主项目和所有子项目源码
git clone --recurse-submodules <main_project_url>
#初始化子模块
# 初始化模块只需在克隆父项目后运行一次
git submodule init # 初始化本地.gitmodules文件
#更新子模块代码
# 更新子模块代码
git submodule update # 同步远端submodule源码
#子模块提交代码步骤:
#提交子模块代码
# 从主项目进入子项目目录
cd src/template/
# 修改子模块代码
# 提交子模块代码
git add .
git commit -m 'XXX'
git push origin dev
#将主模块与子模块相关联的commit id更新到远程
# 进入主项目
git status
# 提示子模块代码有新的提交
#modified: src/template (new commits, modified content)
# 查看两个版本的差异(子模块的commit id更新为最后一次提交)
git diff src/template
#-Subproject commit 475f9e2bfab0201be2628ed3ae41e1496f25dd00
#+Subproject commit 2203a7b0228338748cf0d30f6d46a23165f4665f
# 将主模块与子模块相关联的commit id更新到远程
git add src/template
git commit -m 'update submodule commit id'
git push origin dev