413

When I tried to push an existing repository on github.com, and it when I entered the command the website prompted me to put into the terminal, I got this error message fatal:

Not a git repository (or any of the parent directories): .git

If anyone could help me with this, then that would be great, thanks.

Andrew Marshall
  • 92,562
  • 20
  • 215
  • 211
user3072482
  • 4,199
  • 3
  • 12
  • 5
  • 13
    Are you sure you are CD'd into a git repository directory or subdirectory in your terminal? – jraede Dec 06 '13 at 00:13
  • 1
    This can also happen if you exported your `CDPATH` environment variable, and one of the sub-directories of a repo happens to be named same as another non-repo-subdir under one of the paths in your `CDPATH`. Sounds crazy, but that wasted hours of my time recently before solving it. – MarkHu Jun 16 '17 at 00:09
  • similiar solution https://stackoverflow.com/questions/4630704/git-receiving-fatal-not-a-git-repository-when-attempting-to-remote-add-a-git – CuriousDev May 21 '21 at 07:24

1 Answers1

761

The command has to be entered in the directory of the repository. The error is complaining that your current directory isn't a git repo

  1. Are you in the right directory? Does typing ls show the right files?
  2. Have you initialized the repository yet? Typed git init? (git-init documentation)

Either of those would cause your error.

ΩmegaMan
  • 26,526
  • 10
  • 91
  • 107
Daniel Gratzer
  • 51,647
  • 11
  • 93
  • 131