“fatal: Not a git repository (or any of the parent

2019-01-22 00:45发布

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?

10条回答
太酷不给撩
2楼-- · 2019-01-22 01:16

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.

查看更多
该账号已被封号
3楼-- · 2019-01-22 01:19

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.

查看更多
Melony?
4楼-- · 2019-01-22 01:25

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 
查看更多
Juvenile、少年°
5楼-- · 2019-01-22 01:26

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

This also broke all my local repos in SourceTree :(

查看更多
▲ chillily
6楼-- · 2019-01-22 01:26

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

git clone https://User_Name@bitbucket.org/Repo_Name.git

cd Repo_Name
查看更多
可以哭但决不认输i
7楼-- · 2019-01-22 01:28

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)
查看更多
登录 后发表回答