2014-02-15 54 views
4

當我做git status這是我所看到的:爲什麼git rm -rf沒有擺脫其中具有子模塊的文件夾?

$ git status 
# On branch master 
# Your branch is ahead of 'github/master' by 1 commit. 
# (use "git push" to publish your local commits) 
# 
# Changes not staged for commit: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# (commit or discard the untracked or modified content in submodules) 
# 
# modified: octopress (modified content, untracked content) 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

當我做git rm -rf octopress,這是我所看到的:

$ git rm -rf octopress 
error: submodule 'octopress' (or one of its nested submodules) uses a .git directory 
(use 'rm -rf' if you really want to remove it including all of its history) 

的思考?

回答

0

如果從git的狀態乾淨的輸出後的明明白白,你可以簡單地,

git status --ignore-submodules 

否則,你將需要與子模塊明確地處理。在處理子模塊之前,請注意,git子模塊不應具有.git目錄。你可以使用舊版本的git嗎?

繼續前進。 Git的告訴你的octopress子模塊,它是,

# modified: octopress (modified content, untracked content) 

要解決這一點,你需要進入octopress子模塊和,

  • 復位或提交修改後的內容
  • 提交,刪除或.gitignore未追蹤的內容

或者,使用更大的錘子,正如您似乎建議在que Stion的,你可以從Git的1.8.3刪除子模塊的本地結賬,

$ git submodule deinit --force octopress 

適用及以後

當指定--force,子模塊的工作樹會,即使它包含本地刪除修改。

通過git rm octopress按照這從回購刪除子模塊。


看這個補丁,

移動GIT-dir來子模塊到$ GIT_DIR /模塊/ [name_of_submodule]的 上層項目。這是朝着能夠刪除子目錄 目錄邁出的一步,而不會丟失它們的.git目錄 中的信息,因爲它現在存儲在子模塊工作樹之外。
http://git.661346.n2.nabble.com/PATCH-v5-0-2-submodule-move-gitdir-into-superproject-td6692559.html

3

此錯誤消息弄得我太多,但它是什麼想說的是,你應該使用rm -rfgit rm -rf

(use 'rm -rf' if you really want to remove it including all of its history) 

所以,你應該能夠做到這一點:

$ rm -rf octopress 
$ git rm octopress 
相關問題