git submodule

给项目增加submodule
git submodule add https://github.com/chaconinc/DbConnector

———————
克隆主项目时默认不会将submodule一起克隆

克隆主项目后,需要:
git submodule init
git submodule update

或者:
主项目克隆时直接把submodules一起克隆
git clone –recurse-submodules https://github.com/chaconinc/MainProject

———————
从远程获取更新
进入submodule,
git fetch
git merge origin/master

配置git pull时同时拉取submodule(全局)
git config –global submodule.recurse true

自动合并,默认是master分支,如果不加merge 或rebase,会指向一个detached ID:
git submodule update –remote

git submodule update –remote –merge
git submodule update –remote –rebase

不使用master ,使用其他分支更新,比如dev分支
git config -f .gitmodules submodule.DbConnector.branch dev
git submodule update –remote

————————
git diff 时同时显示submodule的差异:
git config –global diff.submodule log
————————

删除:
git submodule deinit –force usr/plugins/BaiduSubmit

————————
push:

主项目push时把module也自动push
git push –recurse-submodules=on-demand
或者配置
git config push.recurseSubmodules on-demand

不自动push,仅提示
git push –recurse-submodules=check
git config push.recurseSubmodules check

仅push module,不push主项目
–recurse-submodules=only

转载于:https://my.oschina.net/falcon10086/blog/3032863

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值