2011-03-21 63 views

回答

7

你說你要回去之前初始化更新,這將是其中的子模塊仍然存在於.gitmodules,但其未在.git/config註冊的空目錄的情況。

假設你的子模塊被稱爲foo/bar,那麼你可以做到以下幾點:

# Move the submodule out of your repository, just in case you have changes 
# in there that you realise afterwards that you'd like to preserve: 
mv foo/bar/ ~/backups/old-foo-bar/ 

# Recreate the submodule directory, but empty this time: 
mkdir foo/bar/ 

# Remove all the config variables associated with that submodule: 
git config --remove-section submodule.foo/bar 
# Note that the submodule name is *without* the trailing slash 
0

如果變化COMMITED,那麼你應該能夠檢查引用日誌:

git reflog 

一旦你找到了改變設置你失去了,你可以把它合併在

如果。您的變更未提交,則無法恢復。

+0

我想要的是一種保留子模塊的方法,但只需刪除工作區中的填充文件即可。事實證明,我可以刪除目錄,並且不會以任何方式影響子模塊。所以,就我而言,我的子模塊位於名爲projects的目錄中。我可以刪除項目/工具鏈,但內容不見了,但git不記錄刪除。感謝大家嘗試這一個。 – user561638 2011-03-22 14:20:32

1

嘗試(與git1.8.3,四月22D 2013)A:

git submodule deinit 

(請參閱 「How do I remove a Git submodule?」 )

這會從.git/config中刪除整個submodule.<name>部分對於給定的子模塊

雖然您可能必須刪除該子模塊的工作樹。

相關問題