Git repo 错误消息,它不是一个 repo...但它是
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6269486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git repo erroring with message that it's not a repo... but it is
提问by brycemcd
I have a git repo I've been using for the last year on the same box. Today I run git status
and get the error message:
我有一个 git repo,我去年一直在同一个盒子上使用。今天我运行git status
并收到错误消息:
fatal: Not a git repository (or any parent up to mount parent /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
I have a .git directory and it's populated with the thousands of commits I have for that repo. I don't want to re-initialize the repo in fear that it'll overwrite the history. I also don't really want to re-pull it from github as I've got a few changes stashed in branches that I haven't pushed up to GH in a while.
我有一个 .git 目录,里面装满了我对该 repo 的数千个提交。我不想重新初始化 repo,因为它会覆盖历史记录。我也真的不想从 github 重新提取它,因为我有一些更改藏在分支中,我已经有一段时间没有推送到 GH 了。
edit:
编辑:
I'm reasonably sure it's not my environment. Other git repos are working just fine
我很确定这不是我的环境。其他 git repos 工作正常
采纳答案by manojlds
I would like to post some comments from the appropriate source file of git:
我想从相应的 git 源文件中发表一些评论:
Git repo discovery is done as per below:
Git repo 发现按以下方式完成:
/*
* Test in the following order (relative to the cwd):
* - .git (file containing "gitdir: <path>")
* - .git/
* - ./ (bare)
* - ../.git
* - ../.git/
* - ../ (bare)
* - ../../.git/
* etc.
*/
And it ascertains that it is a git repo as below:
它确定它是一个 git repo,如下所示:
/*
* Test if it looks like we're at a git directory.
* We want to see:
*
* - either an objects/ directory _or_ the proper
* GIT_OBJECT_DIRECTORY environment variable
* - a refs/ directory
* - either a HEAD symlink or a HEAD file that is formatted as
* a proper "ref:", or a regular file HEAD that has a properly
* formatted sha1 object name.
*/
See what's wrong with your .git
. This ties in with @Chris Nicola 's answer of the HEAD
being lowercase etc.
看看你的有什么问题.git
。这与@Chris Nicola 对HEAD
小写字母等的回答有关。
回答by Chris Nicola
It's hard to say the exact cause but your .git must be corrupted somehow. There is a blog post herewhere some guy had his HEAD file renamed to all lowercase on his system somehow which caused that problem for him. Not saying that is your particular problem but you may want to look closer at the .git folder.
很难说确切的原因,但您的 .git 必须以某种方式损坏。这里有一篇博客文章,其中有人将他的系统上的 HEAD 文件重命名为全小写,这导致了他的问题。并不是说这是您的特殊问题,但您可能想仔细查看 .git 文件夹。
You could try to checkout from github in a new folder and then compare the two .git folders for differences.
您可以尝试在新文件夹中从 github 签出,然后比较两个 .git 文件夹的差异。
回答by ZenBalance
Another possibility might be that the permissions of your git files have been corrupted. Check to make sure that you have read permissions.
另一种可能是您的 git 文件的权限已损坏。检查以确保您具有读取权限。
I have had a similar problem when my permission are messed up while sshing into a computer.
我遇到了类似的问题,当我的权限在 ssh 进入计算机时搞砸了。
回答by Deepak
Check whether you are giving this command from right directory. I had faced same error. Then I went to the directory where .git is present and gave command.Its working properly.
检查您是否从正确的目录发出此命令。我遇到了同样的错误。然后我去了.git所在的目录并给出命令。它工作正常。
回答by Adam Dymitruk
Clone anyway to another directory. You can copy the object from the .git dir in the original repo with the stashes to the .git folder in the new repo. Skip any files that would be overwritten. You should be able to then copy the stash pointers and gitk --all should show you them.
无论如何克隆到另一个目录。您可以将对象从原始存储库中的 .git 目录中复制到新存储库中的 .git 文件夹中。跳过将被覆盖的任何文件。然后您应该能够复制存储指针并且 gitk --all 应该向您显示它们。