Git repo erroring with message that it's not a repo... but it is
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:
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 .gi开发者_StackOverflow中文版t 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.
edit:
I'm reasonably sure it's not my environment. Other git repos are working just fine
I would like to post some comments from the appropriate source file of git:
Git repo discovery is done as per below:
/*
* 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:
/*
* 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.
It's hard to say the exact cause but your .git must be corrupted somehow. There is a blog post here where 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.
You could try to checkout from github in a new folder and then compare the two .git folders for differences.
Another possibility might be that the permissions of your git files have been corrupted. Check to make sure that you have read permissions.
I have had a similar problem when my permission are messed up while sshing into a computer.
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.
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.
精彩评论