fatal: Not a git repository (or any of the parent directories): .git

Published on Author Code Father
fatal: Not a git repository (or any of the parent directories): .git

I had the same problem after upgrading to Sierra. In addition to brew --prefix, which displays Homebrew’s install path, there’s also brew --repository, which displays where it’s. git directory is located. man brew says that claims that “for standard installs, the prefix and repository are the same directory”. Either the man page is out of date or my install isn’t “standard”, but my prefix is /usr/local and my repository is /usr/local/Homebrew. Using the same command but with cd $(brew --repository) worked for me:

cd $(brew --repository) && git fetch && git reset --hard origin/master

————————–/OR/——————————-

One way to get that error message is to somehow not be in the git repo working tree.
See “After git clone I get a “ fatal: Not a git repository (or any of the parent directories): .git ” error” as an illustration.

It can also be cause because of a GIT_WORK_TREE environment variable being set to the wrong path.
Or it is seen in wrappers using git repo like rvm (see this thread for example)

In both case, resetting the situation in a new clone (which you did) usually is a good way to fix the situation.

 

Comments

comments

Categories Git