git status returns fatal: Not a git repository but .git exists and HEAD has proper permissions

后端 未结 8 684
无人及你
无人及你 2020-12-02 12:24

When I run git status on my repo I get fatal: Not a git repository: /my repo/.git/modules/docs

I\'ve checked and .git exists and contains HEAD with the

相关标签:
8条回答
  • 2020-12-02 12:44

    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.

    0 讨论(0)
  • 2020-12-02 12:49

    Former versions of git used an absolute path to locate the gitdir of a submodule. The solution is as follows:

    1. 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.
    2. Delete all the broken submodule folders: rm -rf broken_submodule_folder
    3. Update the registered submodules: git submodule update. You should see the submodules being checked out.
    0 讨论(0)
提交回复
热议问题