Why doesn't git rm -rf get rid of a folder with a submodule in it?

When I do git status, this is what I see:

$ 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")

When I do git rm -rf octopress, this is what I see:

$ 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)

Thoughts?

+4
source share
2 answers

This error message confused me, but what he is trying to say is that you should use rm -rf, not git rm -rf :

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

So you have to do this:

$ rm -rf octopress
$ git rm octopress
+3
source

If you are clearly after a clean exit from git state, you can simply,

git status --ignore-submodules

Otherwise, you will need to explicitly process the submodule. And before we get into the submodule, note that git submodules should not have directory .git 1 . Could you use the old version of git?

. git octopress, ,

#   modified:   octopress (modified content, untracked content)

, octopress

  • Reset
  • , .gitignore

, , , , , ,

$ git submodule deinit --force octopress

git 1.8.3

--force, , .

git rm octopress, .


< > 1 ,

git -dir $GIT_DIR/modules/[name_of_submodule] of . , .git .
http://git.661346.n2.nabble.com/PATCH-v5-0-2-submodule-move-gitdir-into-superproject-td6692559.html >

0

Source: https://habr.com/ru/post/1527117/


All Articles