484

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.

5
  • 25
    Are you sure you are CD'd into a git repository directory or subdirectory in your terminal? Commented Dec 6, 2013 at 0: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. Commented Jun 16, 2017 at 0:09
  • 1
    similiar solution stackoverflow.com/questions/4630704/… Commented May 21, 2021 at 7:24
  • You need to be in the directory that holds the repo, it typically has the '.gitignore' file. Commented Sep 14, 2022 at 15:06
  • If you previously had an initial commit from local to GitHub remote, or if you previously pulled from remote to local, then you have set up your remote. What worked for me is signing into my remote GitHub repo, and then this error went away and able to push/pull changes from local to remote, and vice versa. Commented Dec 3, 2022 at 22:18

1 Answer 1

851

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.

Sign up to request clarification or add additional context in comments.

14 Comments

I got this error when I opened the gitshell and typed the command --> git remote add origin github.com/ascenttech/Hst.git Any suggestions
I just wanted to add that the error appears even if we are in the correct directory and the repository has been initialized, in case we accidentally delete or pamper with the .git folder.
I had not done "git init" it resolved
In my case I had changed by mistake the permissions of the files in .git
I was getting this error and it turned out to be the permissions set on the .git directory itself. Was 660 .. updated to 770 and everything worked fine.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.