我讀過how to remove a git submodule myself:刪除git submodules - 如何自動刪除拉?
# Delete the relevant section from the .gitmodules file.
git config -f .gitmodules --remove-section submodule.$submodulepath
# Delete the relevant section from .git/config
git config -f .git/config --remove-section submodule.$submodulepath
git rm --cached path_to_submodule # no trailing slash
git commit
rm -rf path_to_submodule
我能做到這一點。但是當別人做了git pull
我們如何確保子模塊從系統中移除?據我所知,.gitmodules
更改與拉,但沒有其他更多。所以拉的人將仍然需要運行
git config -f .git/config --remove-section submodule.$submodulepath
rm -rf path_to_submodule
這是正確的嗎?在一個小型開發團隊中,我想你可以告訴每個人都運行這些命令,但這並不理想。
是否有一些神奇的命令可以自動執行此操作?特別是我希望在部署腳本中使用一些標準的自動化方法。關於我的頭頂,我不確定劇本怎麼會知道有一個比以前少的子模塊。發生在我(不是特別有吸引力)的選項有:
- 上
.gitmodules
做的diff之前和拉 - 刪除所有子模塊,然後運行
git submodule update --init
每一個部署後。 - 該子模塊確實在拉動後最終成爲未跟蹤文件,所以一個可行的選項是在拉動後刪除包含
.git
子目錄的所有未跟蹤目錄,但是您可能會刪除想要保留的東西那樣。
任何更好的選項讚賞。
應該不會命令你執行rm'卸下拉子模型的'git的? – 2013-02-14 15:01:44
@DanielHilgarth:最近我們做了它並沒有被刪除,但也許我沒有做到上面的確切步驟。也許我應該測試一下。 – 2013-02-14 15:09:54
@DanielHilgarth:剛剛檢查過並且'git rm'實際上並沒有刪除子模塊文件,因此在第一組指令結束時會刪除'rm -rf path_to_submodule'。克隆副本還需要手動刪除步驟。這對你來說有什麼不同?如果是這樣,你使用的是什麼版本的git? – 2013-02-14 15:17:42