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:
For the second situation, you need to initialize the Git repository in your project folder. To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.
What does “fatal: not a git repository” mean? This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right directory.
Note: The “fatal: 'origin' does not appear to be a git repository” error occurs when you try to push code to a remote Git repository without telling Git the exact location of the remote repository. To solve this error, use the git remote add command to add a remote to your project.
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.
Make sure you don't have a GIT_DIR
or GIT_WORK_TREE
environment variable set in your current session, which would point to an incorrect folder.
In doubt, try a:
cd /path/to /your/repo
git --git-dir .git --work-tree . status
If that still fails, try at least to clone that repo again from GitHub, and add your recent changes in that new repo:
cd /path/to/new/clone
git --git-dir .git --work-tree /path/to /your/repo add .
(and go on working in that new clone)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With