An error that begins with “fatal” never sounds good. Do not worry; the cause of the fatal: not a git repository (or any of the parent directories): .git error is simple. This error is raised when you try to run a Git command outside of a Git repository.
In this guide, we talk about this error and why it is raised. We walk through two potential solutions so you can learn how to overcome a “not a git repository” error when working with Git. Without further ado, let’s begin!

Find Your Bootcamp Match
- Career Karma matches you with top tech bootcamps
- Access exclusive scholarships and prep courses
By continuing you agree to our Terms of Service and Privacy Policy, and you consent to receive offers and opportunities from Career Karma by telephone, text message, and email.
fatal: not a git repository (or any of the parent directories): .git
The cause of this error message is running a Git command outside of a directory in which a Git folder is initialized. For instance, if you try to run “git commit” in a non-Git folder, you see an error. Git cannot run unless you view a folder configured with Git.
This is because Git is configured in a specific directory. Every Git project has a secret folder called .git/. You can view this folder by running the following command:
ls -la
.git/ contains all of the configuration files for a repository. Without this folder, Git does not know anything about a project. This folder contains information such as the Git remotes associated with a repository, Git environment variables, and your current HEAD.
Run git commit
inside a folder that is not a Git repo:
git commit
This command returns:
fatal: not a git repository (or any of the parent directories): .git
Let’s solve this error.
Two Possible Causes
There are two possible causes for the “not a git repository” error.
Viewing the Wrong Directory
Check whether you view the correct directory. For instance, if you are in your home folder, you are not in a Git folder. If you are in a project folder, ensure it is the one where initialized a Git folder.
No Git Repository Has Been Initialized
If you are in a project folder and you see a “not a git repository” error, check whether a repository is initialized. You can do this by running ls -la
and checking for a .git/ folder.
If no .git/ folder is present, you have not initialized a repository. This means there is no record of Git inside a particular project folder.
To solve this error, run git init in your project folder:
git init
The git init command initializes a new Git repository in your current working directory.
Conclusion
The “not a git repository” error is common. The cause is running a Git command in the wrong folder or running a Git command before initializing a Git repository.
Now you’re ready to solve the “not a git repository” error like an expert developer!
About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication.