If you try to run a git command to add a file to stage area or commit your current state files into your local branch on the terminal and you get the fatal error "not a git repository",
Reasons:- The most likely reason is that you are not in a git directory, do a pwd and confirm.
- If this is supposed to be a new repository, then go a git init to initialize the directory as a git repo.
- Check if the directory has a .git folder in it (ls -la).
- If this directory you are in is supposed to be a new git project then run git init

As you may see in the above screenshot when I did a git add, I got the fatal error saying the current directory is not a git repository, when I did a ls -la, there is not .git folder, and for me, it was supposed to be a new git repo, so I did git init and then tried the git add command and it worked like a charm.
Happy coding!
- [Fixed] Git Clone git@github.com: Permission denied (publickey) Could not read from remote repository Fatal error
- Github: How to Invite Collaborators
- Git Commit - Author identity unknown, Please tell me who you are email
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- [fix] zsh: command not found: git
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021
- Get List of all local branches git command
- Git Revision Questions Before the Interview
- git fatal: Authentication failed error [fix]
- How to Install Git on Ubuntu Linux
- GitHub: How to Search Code
- How to change Git Default Author and Committer details in Eclipse
- How to check your installed version of Git
- Install GitHub Command Line Tool on Mac
- How to Merge Branch into Master Branch
- Perform an Empty Commit in Git without anything in Staging Area
- Git Fix: fatal: refusing to merge unrelated histories Error
- How to undo last Git Commit on Local Repository?
- git command to remove/unstage files from staging area
- Step-by-Step: Setting up Docker + Ubuntu Linux + Git + GitHub Tutorial
- Remove git config at Local, Global or System Levels?
- Fix [oh-my-zsh] Cant update: not a git repository
- Git Config Command - A Deep Dive
- fatal: Unable to create '/c/git_repo/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.
- How to change directory in Git bash
- SharePoint - The URL is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web. - SharePoint
- How to uninstall GarageBand from Mac - MacOS
- How to uninstall Microsoft Edge from Mac (macOS) - MacOS
- Program 4: Input Name and Age and Print - 1000+ Python Programs - Python-Programs
- How to Screenshot on Mac Ventura 13 - Step by Step Guide - MacOS
- Fix PowerShell - .ps1 cannot be loaded because running scripts is disabled on this system - Powershell
- Android : Neither user 10085 nor current process has android.permission.ACCESS_NETWORK_STATE - Android
- Mac turn dark mode on or off using terminal command - MacOS