"fatal: Not a git repository (or any of the parent directories)" from git status
Solution 1
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)
Solution 2
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.
Solution 3
In my case, was an environment variable GIT_DIR
, which I added to access faster.
This also broke all my local repos in SourceTree :(
Solution 4
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
Solution 5
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
Related videos on Youtube
Kevin Kostlan
Updated on June 17, 2020Comments
-
Kevin Kostlan almost 4 years
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 abovefatal: Not a git repository (or any of the parent directories)
error.What am I doing wrong?
-
Eugen Constantin Dinca over 11 yearsThe checked-out code is in the
liggghts
directory.
-
-
Cerin over 5 yearsYou also get this error when git hoses it's own .git directory. I did a pull, and saw the message "Auto packing the repository in background for optimum performance." I then tried to do some more operations, only getting OP's error message. My .git folder is still there, but git has somehow corrupted it. Running
git init
fixed the problem. -
Michael Durrant over 4 yearsBefore or after the clone? Would this create a new git repo? How would this work with the existing git repo and history that was cloned? What happens to the original
remote
setting under this arrangement? -
webHasan about 4 yearsHow stupid I am. Trying git status before going to the directory :) Thank you so much.
-
Scott Wade almost 4 yearsI was getting the error just trying to clone a repo to my local machine. I switched FROM using https:// TO git:// and it was successfully cloned. Thx for pointing me in the right direction.