I'm trying to remove a git submodule but I'm getting the following error:
❯ git rm -rf lua-filters/
fatal: cannot chdir to '../../../../../pandoc-filters/pandoc/lua-filters': No such file or directory
fatal: could not recurse into submodule 'pandoc/pandoc/lua-filters'
By googling the error message the only significant result is the git source code that prints it.
I'm also not able to list submodules:
➜ git submodule status --recursive
fatal: no submodule mapping found in .gitmodules for path 'pandoc/pandoc/lua-filters'
What is wrong with my repo?
Where is my .gitmodules
:
[submodule "pandoc/fonts-and-alignment"]
path = pandoc/fonts-and-alignment
url = https://github.com/pandoc-ext/fonts-and-alignment
[submodule "pandoc/abstract-section"]
path = pandoc/abstract-section
url = https://github.com/pandoc-ext/abstract-section
[submodule "pandoc-filters/pandoc-filters/pandoc-ext/abstract-section"]
path = pandoc-filters/pandoc-filters/pandoc-ext/abstract-section
url = https://github.com/pandoc-ext/abstract-section
[submodule "pandoc-filters/pandoc/pandoc/lua-filters"]
path = pandoc-filters/pandoc/pandoc/lua-filters
url = https://github.com/pandoc/lua-filters/
[submodule "pandoc-filters/lua-filters"]
path = pandoc-filters/lua-filters
url = https://github.com/pandoc/lua-filters/
[submodule "pandoc-filters/pandoc/lua-filters"]
path = pandoc-filters/pandoc/lua-filters
url = https://github.com/pandoc/lua-filters/
[submodule "pandoc-filters/pandoc-ext/abstract-section"]
path = pandoc-filters/pandoc-ext/abstract-section
url = https://github.com/pandoc-ext/abstract-section
[submodule "pandoc-filters/pandoc-ext/fonts-and-alignment"]
path = pandoc-filters/pandoc-ext/fonts-and-alignment
url = https://github.com/pandoc-ext/fonts-and-alignment
Removing submodules from a git repository requires some steps. I've followed a step by step guide from a freeCodeCamp webpage in the past, and it worked very weell (see this freeCodeCamp page for the original text).
These are the steps (copied from the link mentioned above):
- Delete the section referring to the submodule from the
.gitmodules
file- Stage the changes via
git add .gitmodules
- Delete the relevant section of the submodule from
.git/config
- Run
git rm --cached path_to_submodule
(no trailing slash)- Run
rm -rf .git/modules/path_to_submodule
- Commit the changes with
git commit -m "Removed submodule"
- Delete the now untracked submodule files
rm -rf path_to_submodule
There is no entry for pandoc/pandoc/lua-filters
in your .gitmodules
file, but probably this path still appears somewhere else.
I'd try to follow the above mentioned steps, in order to remove everything regarding that submodule.
Another question:
In what working directory do you call git rm -rf lua-filters/
? Removing the submodule with this command should be done from the repo's root directory with the full submodule path. I've noticed you have the same external repo added multiple times to different locations in your .gitmodules
file. This may cause some confusion.