git status returns fatal: Not a git repository but .git exists and HEAD has proper permissions
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.
Former versions of git used an absolute path to locate the gitdir of a submodule. The solution is as follows:
- Upgrade git to the latest version. Some says you'll need at least version 1.7.10. I just successfully solved the issue with git 1.8.3.
- Delete all the broken submodule folders:
rm -rf broken_submodule_folder
- Update the registered submodules:
git submodule update
. You should see the submodules being checked out.
I finally sorted out that the issue was due to an issue with one of the submodules. Simply renaming the repo directory caused a conflict with that submodule. After seeing the discussion in How can I rename a git repository with submodules? I realized that cloning the repo is a better way to go instead of renaming the directory and that solved the issue with the submodule.