Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git status returns "fatal: Not a git repository" yet .git directory exists

Tags:

git

I have a remote folder that I am currently unable to push to. When I go directly to the remote directory and a do a 'git status' it reads:

fatal: Not a git repository

The .git folder does exists and it was working fine yesterday and nothing has changed since.

Can anyone tell me the reason(s) why I might receive this message even though the .git folder exists?

Thanks in advance for your help. Much appreciated!

like image 258
BIOSTALL Avatar asked Dec 08 '11 16:12

BIOSTALL


People also ask

Is git status a fatal error?

However, git status (or any other git command) then gives the above fatal: Not a git repository (or any of the parent directories) error. What am I doing wrong?

What is Git not a git repository error?

This fatal error "not a git repository" is produced when you are running any git command on a non-git project location. For example, run the git status command to see the current status of the git stage. In the below example, I have created a new folder and executed the git status command.

Why am I getting a Git error when running a command?

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. Check with `ls`. Initialized your repository with `git init` or by cloning an existing repo.

How to initialize the git repository in a project folder?

Solution#01: Initialize the Git Repository in your Project Folder. If you are in your project folder, first check if this directory is initialized with git. Use the command ls -la to check this. If you are in git initialized folder you will see the .git/ folder in the output of the project.


2 Answers

If the permissions on the .git folder are fine, see that there is a file .git/HEAD existing or is not named wrongly like .git/head. The presence of .git/HEAD ( or HEAD in case of bare) is the secondary check for a git repository

like image 144
manojlds Avatar answered Nov 15 '22 19:11

manojlds


Clone the remote repository into another folder and compare the .git folders. This will give you indication about missing or corrupted files. You'll probably see a difference in the objects folder that you can ignore.

like image 30
yorammi Avatar answered Nov 15 '22 17:11

yorammi