2014-01-07 54 views
3

我試着刪除一個子模塊,然後用git 1.8.5.2添加它。 子模塊asub增加了git submodule add -b master url_asub.git。 我通過爲什麼刪除後我不能添加一個git子模塊

git rm asub 

去除輔助模塊中的ASUB目錄不見了。然後我試圖與它添加原始命令重新添加(以測試子模塊去除1.8.5.2是乾淨的):

git submodule add -b master url_asub.git 

我得到一個錯誤信息:

A git directory for 'asub' is found locally with remote(s): 
    origin url_asub.git 
If you want to reuse this local git directory instead of cloning again from 
    url_asub.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. 

我不確定這個錯誤信息的含義。我也試過在上層項目做git submodule sync,並試圖

git submodule deinit asub 
git rm asub 
git submodule add -b master url_asub.git 

但我仍不能添加子模塊背部。我錯過了什麼,或者這是git 1.8.5.2中的錯誤?

我想這樣做的原因是a)刪除子模塊並b)將其添加回來以便它反映子模塊的最新內容。這聽起來似乎天真,但我發現submodule add -b功能會在我克隆超級項目(how to keep git submodule on-branch status after cloning superproject?)後立即中斷。所以我想出一個簡單的方法來避免讓子模塊跟蹤他們的主分支的所有麻煩就是刪除子模塊,並在每次克隆超級項目時將其添加回去。

回答

3

一些greping後,我發現,經過

git submodule add -b master url_asub.git 
git rm asub 

需要第三步驟:

rm -f .git/modules/asub 

的錯誤消息表明因爲git的/模塊/ ASUB保持git rm後,去刪除子目錄後移開。現在子模塊asub可以以我喜歡的任何方式添加回來。

0

如果您所做的只是刪除文件,那麼git submodule update應該再次將其拉下。

相關問題