赞
踩
摘要:本文介绍了包含有git Submodule的常用操作,包含创建Submodule,拉取,提交等常用开发操作.
在.git的同级目录下执行:
git submodule add <url>
注意:要确保协同开发主仓库的所有人员,都可以访问<url>;
在仓库中增加完毕submodule后,要执行提交(commit)和推送(push)操作;
先设置显示子模块的简明信息:
git config status.submodulesummary 1
查看状态,包含子模块的信息:
git status
查看子项目的日志记录:
git log -p --submodule
查看空间中某一submodule状态:
git diff --cached <submodule_package_file_name>
查看空间中全部submodule状态:
git diff --cached --submodule
克隆项目,默认带有空的Submodule文件夹:
git clone <url> [<rename>]
初始化Submodule:
git submodule init
更新Submodule中的内容至当前版本:
git submodule update
git clone --recurse-submodules <url> [<rename>]
git fetch <url> [<branch-name>:<branch-name>]
git merge <branch_name>
git submodule update --remote [<submodule-name>]
需要建立分支temp继承游离分支HEAD:
git branch temp HEAD
在master分支中合并temp分支:
git checkout master
git merge temp
git submodule update --remote --merge
git submodule update --remote --rebase
git pull <remote-name> --recurse-submodules
如果 .gitmodules 文件中记录的子模块的 URL 发生了改变:
# 将新的 URL 复制到本地配置中
git submodule sync --recursive
# 从新 URL 更新子模块
git submodule update --init --recursive
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。