Search code examples
gitgithubgit-submodules

Git: Removing submodule error


I'm trying to remove submodule from my repo. This are the steps I'm using to remove the repo:

Delete the relevant section from the .gitmodules file.
Stage the .gitmodules changes git add .gitmodules
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule 

But when I ran this command git rm --cached path_to_submodule I get this error:

fatal: Please stage your changes to .gitmodules or stash them to proceed

If ran git status I get this message:

fatal: Not a git repository:path to submodule

Any of you knows why or how can I remove the submodule?

I'll really appreciate your help.


Solution

  • You might need to first unregister the submodule.

    git submodule deinit <path_to_submodule>