git不是git仓库(或任何父目录).git [英] git fatal not a git repository (or any of the parent directories) .git

查看:2496
本文介绍了git不是git仓库(或任何父目录).git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是git仓库(或任何父目录).git
是我在尝试执行任何git时遇到的错误在我的回购操作。
我对我的项目进行了一些更改,这是回购,然后我尝试通过git状态来查看我的更改并遇到此错误。我谷歌搜索这个错误,但没有取得任何进展。看起来这个错误在试图在repo之外的目录中执行git操作时最为常见,而这对于我来说并非如此。
我也尝试检查我的 ./git/HEAD ./git/logs/refs/head 两者都是空文件。 ./git/logs/refs/remotes/origin/master也是空的。

因此,从一开始:


  • 我在一台计算机上的这个目录中创建了一个Android项目。

  • 我在这个目录上启动了一个git并将其发布到github上。 b $ b
  • 我遵循常用的在线指南,将此回购协议拉到另外两台
    计算机上。
  • 在另一台计算机上进行了一些更改,将更改推送到
    $回购

  • 然后在原来的计算机上,我成功取消了更改。

  • 几天后,在原始计算机上进行了一些更改
    ,试图进行git状态并发生这种情况。 p>在我的例子中,不小心使用了 .git / HEAD 文件, >文件没问题(它有commit id)。因此,我将 .git / ORIG_HEAD 内容复制到 .git / HEAD 文件中。然后重新启动IDE(Aptana),一切正常。

    fatal not a git repository (or any of the parent directories) .git is the error I'm getting when I try to perform any git operation on my repo. I made some changes to my project which is the repo then I try to git status to look over my changes and encounter this error. I Googled this error but didn't make any progress. It seems this error is most common when trying to perform git operations in a directory that's outside the repo which isn't the case for me. Also I tried checking my ./git/HEAD and ./git/logs/refs/heads both of which are empty files. ./git/logs/refs/remotes/origin/master is also empty.

    So from the beginning:

    • I made an Android project in this directory on one computer.
    • I initiated a git on this directory and posted it on github.
    • I followed the usual online guides for pulling this repo onto 2 other computers.
    • Made some changes on another computer, pushed the changes to the repo.
    • Then on the original computer I successfully pulled the changes.
    • After not working on the project for a few days, I made some changes on the original computer, tried to git status and this happens.

    解决方案

    In my case, accidentally .git/HEAD file was messed up with non unknown characters, but .git/ORIG_HEAD file was ok (it has commit id). So, I copied .git/ORIG_HEAD content to .git/HEAD file. Then restarted IDE (Aptana) and everything worked fine.

    这篇关于git不是git仓库(或任何父目录).git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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