git状态返回致命错误:不是git存储库,但存在.git,HEAD具有适当的权限 [英] git status returns fatal: Not a git repository but .git exists and HEAD has proper permissions

查看:380
本文介绍了git状态返回致命错误:不是git存储库,但存在.git,HEAD具有适当的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在repo上运行git status时,我得到了 fatal:不是git仓库:/ my repo / .git / modules / docs



我已检查并存在.git,并包含具有适当权限的HEAD。我可以很好地运行其他各种命令。如果我运行git gui,它会打开并且会列出一些已更改的文件,但缺少很多这些文件。



我猜可能会有某种排序HEAD的腐败现象,但不知道。任何想法如何解决这个问题,而不消除整个回购?

更新:我意识到我已经更改了repo目录的名称。错误中引用的目录是该目录的旧名称。所以我目前的回购是在 / new dir / .git 但是错误是说不是git存储库:/ old dir / .git / modules /文档。所以,也许git很困惑?

解决方案

我终于解决了这个问题是由于其中一个子模块的问题。简单地重命名repo目录会导致与该子模块的冲突。在中查看讨论后,如何使用子模块重命名git存储库?我意识到,克隆repo是一种更好的方式,而不是重命名目录并解决了子模块的问题。


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?

解决方案

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.

这篇关于git状态返回致命错误:不是git存储库,但存在.git,HEAD具有适当的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆