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

后端 未结 8 746
无人及你
无人及你 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:33

    Solution :

    1) Look into the HEAD file (under .git) -> If it is corrupted (contains some random values), replace the content with this text 'ref: refs/heads/develop' (develop is the last branch I was working on)

    2) try - git status.

    3) If step 2 doesn't solve your issue, try these commands (may not work for all but worth a try)

    rm -f .git/index git reset

    4) git will give you unstaged files after reset. keep or discard as per your wish

提交回复
热议问题