Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
748 views
in Technique[技术] by (71.8m points)

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

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 proper permissions. I can run various other commands fine. If I run git gui it opens fine and will list a couple of the changed files, but is missing a lot of them.

I'm guessing there may be some sort of corruption in HEAD, not sure though. Any idea how to fix this without wiping out the whole repo?

Update: I realized that I had changed the name of the repo's directory. The directory being referenced in the error is the old name of the directory. So my current repo is at /new dir/.git but the error is saying Not a git repository: /old dir/.git/modules/docs. So maybe git is confused?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...