I was trying to remove one sub-module from the project
Tried rm -rf .git/modules/submodulePath
After that I am having the issue
fatal: Not a git repository
I was trying to remove one sub-module from the project
Tried rm -rf .git/modules/submodulePath
After that I am having the issue
fatal: Not a git repository
These two files contains absolute submodule path:
{submodule}/.git
.git/modules/{submodule}/config
So, if you moved the repo, the absolute path in these two files are not valid, and cause the 'not a git repository' error. Just fix these files manually.
Update:
Delete the relevant section from the .gitmodules file. You can use below command:
git config -f .gitmodules --remove-section "submodule.submodule_name"
Stage the .gitmodules changes
git add .gitmodules
Delete the relevant section from .git/config. You can use below command:
git submodule deinit -f "submodule_name"
Remove the gitlink (no trailing slash):
git rm --cached path_to_submodule
Cleanup the .git/modules:
rm -rf .git/modules/path_to_submodule
Commit:
git commit -m "Removed submodule <name>"
Delete the now untracked submodule files
rm -rf path_to_submodule
git reset
after editing the .git/config file –
Delrio 2.27.0
. –
Secretariat submodule deinit
here, thanks for the info! –
Prank I ran into this and didn't have a .git/modules
directory in my main repository. I have one submodule 'build', so just removed any references and reinitialized it:
rm -rf .git/modules
rm -rf build
git submodule init
git submodule update
rd /s /q <dir>
for cmd or rd -r <dir>
in powershell. https://mcmap.net/q/56117/-quot-rm-rf-quot-equivalent-for-windows –
Gourd Remove-Item <dir> -Recurse -Force
may be better for powershell #25798772 –
Gourd I've just hit this problem.
In my case, this was due to checkout branches with different submodules.
For some reason, they were impossible to initialize with:
git submodule update --recursive --init
I've needed to manually delete this files/diretories before update worked properly.
{submodule-path}/.git
.git/modules/{submodule}/config
rm -rf submodule-path
. Thanks ~ –
Himyaritic I ran into this error after I moved a git repository to a different folder. When I looked in:
{submodule}/.git
I saw a single line with an absolute path, e.g.:
gitdir: /Users/ajx/Documents/repo/.git/modules/{submodule}
I changed this to a relative path, e.g.:
gitdir: ../../.git/modules/{submodule}
I'm not sure why git would hardcode absolute paths...
You simply can update the .git file
nano {my submodule}/.git
with the right gitdir.
Because i think you change the path of your folder
In my case, When I try to git commit -m "***"
,this problrm occurs:
fatal: not a git repository: library-sp18/../.git/modules/library-sp18
My solution:
delete the .git
file in library-sp18 and git init
I also experienced this issue when changing from my develop branch to a feature branch that contains a new submodule.
After testing all the above solutions, I noticed that the cause was a git config option: submodule.recurse = true
It was trying to fetch the module at checkout but the submodule was not well initialized.
.git/config
rm -rf {submodule-path}
rm -rf .git/modules/*
These are all the areas that submodule information is kept
© 2022 - 2024 — McMap. All rights reserved.