1. 優(yōu)雅的刪除子模塊
# 逆初始化模塊,其中{MOD_NAME}為模塊目錄投放,執(zhí)行后可發(fā)現(xiàn)模塊目錄被清空
git submodule deinit {MOD_NAME}
# 刪除.gitmodules中記錄的模塊信息(--cached選項(xiàng)清除.git/modules中的緩存)
git rm --cached {MOD_NAME}
# 提交更改到代碼庫(kù),可觀察到'.gitmodules'內(nèi)容發(fā)生變更
git commit -am "Remove a submodule."
Done! Nice & clean!
2. 修改某模塊URL
- 修改'.gitmodules'文件中對(duì)應(yīng)模塊的”url“屬性;
- 使用
git submodule sync
命令,將新的URL更新到文件.git/config
;
thinker-g@localhost: ~/app$ git submodule sync
Synchronizing submodule url for 'gitmods/thinker_g/Helpers'
thinker-g@localhost: ~/app$ # 運(yùn)行后可觀察到'.git/config'中對(duì)應(yīng)模塊的url屬性被更新
thinker-g@localhost: ~/app$ git commit -am "Update submodule url." # 提交變更
PS: 本實(shí)驗(yàn)使用git 2.7.4 完成,較低版本git可能不能自動(dòng)更新.git/config
文件,需要修修改完".gitmodule"文件后手動(dòng)修改.git/config
.
以上韩脏。