重新添加git 子子產品出現的問題:
A git directory for 'formRenderLib' is found locally with remote(s):
origin [email protected]:newcare/formRenderLib.git
If you want to reuse this local git directory instead of cloning again from
[email protected]:newcare/formRenderLib.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
說明沒有删除幹淨之前的module
解決方法:
- 在主項目目錄下打開指令行工具執行指令
删除指定子產品的檔案git rm --cached path_to_submodule
-
打開主項目目錄下 .gitmodules (可能會隐藏,需要顯示設定)檔案 删除如下類似内容:
mac下使用指令
可打開vim編輯vim .gitmodules
[submodule "path_to_submodule"] path = path_to_submodule url = https://github.com/path_to_submodule
-
打開主項目目錄下 .git/config 檔案 删除如下内容:
同樣可使用vim編輯
[submodule "path_to_submodule"] url = https://github.com/path_to_submodule
- 使用指令行工具執行指令:
删除.git下的緩存子產品rm -rf .git/modules/path_to_submodule
最後使用如下指令即可添加子子產品
git submodule add https://github.com/path_to_submodule
參考
Git Submodule管理子子產品
vim編輯器使用