Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"fatal: Not a git repository (or any of the parent directories)" from git status

This command works to get the files and compile them:

git clone a-valid-git-url

for example:

git clone git://cfdem.git.sourceforge.net/gitroot/cfdem/liggghts

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?

like image 451
Kevin Kostlan Avatar asked Aug 14 '12 22:08

Kevin Kostlan


People also ask

How do I resolve a fatal error in git?

A Git command needs to be run on a specific repository, so this error typically occurs when a Git command is run in a directory that Git doesn't know about. In these cases, the fix is to make sure that you are both working in the correct folder and that you set up your repository right.

What does not a git repository or any of the parent directories ): .git mean?

This means there is no record of Git inside a particular project folder. The git init command initializes a new Git repository in your current working directory.

Does not appear to be a git repository fatal could not read from remote repository?

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.


11 Answers

You have to actually cd into the directory first:

$ git clone git://cfdem.git.sourceforge.net/gitroot/cfdem/liggghts
Cloning into 'liggghts'...
remote: Counting objects: 3005, done.
remote: Compressing objects: 100% (2141/2141), done.
remote: Total 3005 (delta 1052), reused 2714 (delta 827)
Receiving objects: 100% (3005/3005), 23.80 MiB | 2.22 MiB/s, done.
Resolving deltas: 100% (1052/1052), done.

$ git status
fatal: Not a git repository (or any of the parent directories): .git
$ cd liggghts/
$ git status
# On branch master
nothing to commit (working directory clean)
like image 152
Michael Durrant Avatar answered Oct 20 '22 05:10

Michael Durrant


I just got this message and there is a very simple answer before trying the others. At the parent directory, type git init

This will initialize the directory for git. Then git add and git commit should work.

like image 25
Bill Avatar answered Oct 20 '22 06:10

Bill


In my case, was an environment variable GIT_DIR, which I added to access faster.

This also broke all my local repos in SourceTree :(

like image 20
lucasvc Avatar answered Oct 20 '22 04:10

lucasvc


Sometimes its because of ssh. So you can use this:

git clone https://cfdem.git.sourceforge.net/gitroot/cfdem/liggghts

instead of:

git clone git://cfdem.git.sourceforge.net/gitroot/cfdem/liggghts
like image 37
Umit Kaya Avatar answered Oct 20 '22 06:10

Umit Kaya


in my case, i had the same problem while i try any git -- commands (eg git status) using windows cmd. so what i do is after installing git for window https://windows.github.com/ in the environmental variables, add the class path of the git on the "PATH" varaiable. usually the git will installed on C:/user/"username"/appdata/local/git/bin add this on the PATH in the environmental variable

and one more thing on the cmd go to your git repository or cd to where your clone are on your window usually they will be stored on the documents under github

cd Document/Github/yourproject

after that you can have any git commands

like image 45
keyo Avatar answered Oct 20 '22 04:10

keyo


git clone https://github.com/klevamane/projone.git
Cloning into 'projone'...
remote: Counting objects: 81, done.
remote: Compressing objects: 100% (66/66), done.
remote: Total 81 (delta 13), reused 78 (delta 13), pack-reused 0
Unpacking objects: 100% (81/81), done.

you have to "cd projone"

then you can check status.


One reason why this was difficult to notice at first, i because you created a folder with the same name already in your computer and that was where you cloned the project into, so you have to change directory again


like image 20
Onengiye Richard Avatar answered Oct 20 '22 04:10

Onengiye Richard


I had another problem. I was in a git directory, but got there through a symlink. I had to go into the directory directly (i.e. not through the symlink) then it worked fine.

like image 33
Frank Conry Avatar answered Oct 20 '22 05:10

Frank Conry


This error got resolved when I tried initialising the git using git init . It worked

like image 41
Roopal Avatar answered Oct 20 '22 05:10

Roopal


If Existing Project Solution is planned to move on TSF in VS Code:

open Terminal and run following commands:

  1. Initialize git in that folder (root Directory)

    git init

  2. Add Git

    git add .

  3. Link your TSf/Git to that Project - {url} replace with your git address

    git remote add origin {url}

  4. Commit those Changes:

    git commit -m "initial commit"

  5. Push - I pushed code as version1 you can use any name for your branch

    git push origin HEAD:Version1

like image 39
Khushboo Tahir Avatar answered Oct 20 '22 05:10

Khushboo Tahir


In my case, the original repository was a bare one.

So, I had to type (in windows):

mkdir   dest
cd dest
git init
git remote add origin a\valid\yet\bare\repository
git pull origin master

To check if a repository is a bare one:

git rev-parse --is-bare-repository 
like image 29
Madlozoz Avatar answered Oct 20 '22 06:10

Madlozoz


Simply, after you clone the repo you need to cd (change your current directory) to the new cloned folder

git clone https://[email protected]/Repo_Name.git

cd Repo_Name
like image 43
Abdallah Okasha Avatar answered Oct 20 '22 05:10

Abdallah Okasha