1. 優雅的刪除子模塊
# 逆初始化模塊,其中{MOD_NAME}為模塊目錄,執行后可發現模塊目錄被清空
git submodule deinit {MOD_NAME}
# 刪除.gitmodules中記錄的模塊信息(--cached選項清除.git/modules中的緩存)
git rm --cached {MOD_NAME}
# 提交更改到代碼庫,可觀察到'.gitmodules'內容發生變更
git commit -am "Remove a submodule."
2. 修改某模塊URL
- 修改'.gitmodules'文件中對應模塊的”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$ # 運行后可觀察到'.git/config'中對應模塊的url屬性被更新
thinker-g@localhost: ~/app$ git commit -am "Update submodule url." # 提交變更