git fatal not a git repository (or any of the parent directories) .git
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)
I too had the same issue. The problem was my git folder was being synced by UbuntuOne cloud service. It had messed up the files by adding files appended with u1conflict. And my .git/HEAD was also messed up as .git/HEAD.u1conflict.
Are you using any cloud collaborating services on the git? Dropbox, UbuntuOne etc. Chances are that your .git folder might have got messed up in the process of syncing.