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

后端 未结 13 2249
深忆病人
深忆病人 2020-12-04 14:54

This command works to get the files and compile them:

git clone a-valid-git-url

for example:

git clone git://cfdem.git.sour         


        
相关标签:
13条回答
  • 2020-12-04 15:41

    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.

    0 讨论(0)
  • 2020-12-04 15:41

    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
    
    0 讨论(0)
  • 2020-12-04 15:42

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

    This also broke all my local repos in SourceTree :(

    0 讨论(0)
  • 2020-12-04 15:42

    I suddenly got an error like in any directory I tried to run any git command from:

    fatal: Not a git repository: /Users/me/Desktop/../../.git/modules/some-submodule

    For me, turned out I had a hidden file .git on my Desktop with the content:

    gitdir: ../../.git/modules/some-module

    Removed that file and fixed.

    0 讨论(0)
  • 2020-12-04 15:45

    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
    
    0 讨论(0)
  • 2020-12-04 15:46

    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)
    
    0 讨论(0)
提交回复
热议问题