吃了我的 submodule 給我還回來

在使用 SourceTree 的過程中,你可能會遇到這樣詭異的事情,把一個 SubmoduleA 右擊刪除后,再添加一個SubmoduleB,竟然怎么都顯示不出來???正常情況下把鼠標(biāo)移到 SUBMODULES 標(biāo)簽上 會有 Show/Hide 按鈕,點(diǎn)擊可顯示或隱藏具體子模塊……難道是我打開的方式不對?

其實(shí),只要在終端輸入命令
$ git rm --cached { SubmoduleA 路徑}
把 SubmoduleA 移除后,SubmoduleB 就可以正常顯示了。

然而,直接右擊刪除 submodule 方式是無法徹底刪除的
正確刪除方法在 stackoverflow 上有相關(guān)討論

Via the page Git Submodule Tutorial:
To remove a submodule you need to:

  1. Delete the relevant section from the .gitmodules file.
  2. Stage the .gitmodules changes git add .gitmodules
  3. Delete the relevant section from .git/config.
  4. Run git rm --cached path_to_submodule (no trailing slash).
  5. Run rm -rf .git/modules/path_to_submodule
  6. Commit git commit -m "Removed submodule <name>"
  7. Delete the now untracked submodule files rm -rf path_to_submodule

參考
SourceTree does not show submodules
How do I remove a submodule?

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容