如何優雅的刪除子模塊(submodule)或修改Submodule URL


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

  1. 修改'.gitmodules'文件中對應模塊的”url“屬性;
  2. 使用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." # 提交變更


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM