fatal: not a git repository

Git searched this folder and every folder above it and found no repository, so the command has nothing to work on.

Terminal
fatal: not a git repository (or any of the parent directories): .git

Also appears as

  • fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Prompt to fix it

Git says "fatal: not a git repository (or any of the parent directories): .git". Check which folder the command runs in and whether this project already has a .git folder or a GitHub repository. If we’re in the wrong folder, switch to the right one. If the files came from a ZIP or export of an existing GitHub repo, clone that repo and bring my changes into the clone. Only run git init for a brand-new project, and show me the commands before you add a remote or push.

Paste into Layerwise or any AI coding tool.

What it means

A git repository is a project folder with a hidden .git folder inside, which holds the history. Every git command starts in the current folder and walks up through the parent folders looking for .git. This error means it reached the top without finding one.

Usually the terminal is simply in the wrong place: your home folder, a parent folder, or a different project. Downloaded projects are the other common case. A ZIP download from GitHub, or an export from an AI builder, contains the files without the hidden .git folder, so it has no history and no link to the GitHub repository.

Running git init makes the message go away but starts a brand-new, empty history. If the project already lives on GitHub, clone it and copy your changed files into the clone. Otherwise the two histories share no commits, and your first push gets rejected. In Docker and CI, the “filesystem boundary” variant usually means .git wasn’t copied into the container.

Common causes

  • The terminal is in the wrong folder, such as your home folder or the folder above the project.
  • The project came from a ZIP download or export, which leaves out the hidden .git folder.
  • The project was created locally and never put under git.
  • A Docker build or CI step runs git, but .dockerignore or the checkout step left .git out.

How to fix it

  1. Run pwd to see where you are (cd with no arguments in Windows Command Prompt), then cd into the project folder that contains package.json.
  2. Run git status again. If it works, you were in the wrong folder.
  3. If the project is already on GitHub, run git clone https://github.com/acme/my-app.git and work in that folder.
  4. If it’s a new project, check that .gitignore lists node_modules and .env, then run git init, commit, and connect it to an empty GitHub repository.
  5. In Docker or CI, keep .git in the build context, or pass values like the commit hash in as build arguments.

Example fix

# Where am I, and is there a .git folder here?
pwd
ls -a

# New project only. Check .gitignore lists node_modules and .env first.
git init
git add .
git commit -m "First commit"
git branch -M main
git remote add origin https://github.com/acme/my-app.git
git push -u origin main
All errors
To https://github.com/acme/my-app.git ! [rejected] main -> main (fetch first) error: failed to push some refs to 'https://github.com/acme/my-app.git' hint: Updates were rejected because the remote contains work that you do not hint: have locally. This is usually caused by another repository pushing to hint: the same ref. If you want to integrate the remote changes, use hint: 'git pull' before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Failed to push some refs

GitHub has commits your copy doesn’t, so git refused to overwrite them until you bring those changes in.

> my-app@0.0.0 dev > vite sh: vite: command not found

vite: command not found

The shell couldn’t find the vite program, almost always because the project’s packages aren’t installed or the command ran in the wrong folder.

Auto-merging src/App.tsx CONFLICT (content): Merge conflict in src/App.tsx Automatic merge failed; fix conflicts and then commit the result.

CONFLICT (content): Merge conflict

Both versions changed the same lines in different ways, and git needs you to decide what the file should say before it finishes.

remote: error: GH013: Repository rule violations found for refs/heads/main. remote: remote: - GITHUB PUSH PROTECTION remote: ————————————————————————————————————————— remote: Resolve the following violations before pushing again remote: remote: - Push cannot contain secrets remote: remote: remote: (?) Learn how to resolve a blocked push remote: https://docs.github.com/code-security/secret-scanning/working-with-secret-scanning-and-push-protection/working-with-push-protection-from-the-command-line#resolving-a-blocked-push remote: remote: remote: —— OpenAI API Key ———————————————————————————————————— remote: locations: remote: - commit: 3f9c2a1d8e7b6c5a4f3e2d1c0b9a8f7e6d5c4b3a remote: path: .env:2 remote: remote: (?) To push, remove secret from commit(s) or follow this URL to allow the secret. remote: https://github.com/acme/my-app/security/secret-scanning/unblock-secret/2pXk9vQmT4bL7nRw1sYc8ZfHj3e remote: To https://github.com/acme/my-app.git ! [remote rejected] main -> main (push declined due to repository rule violations) error: failed to push some refs to 'https://github.com/acme/my-app.git'

GH013: Push cannot contain secrets

GitHub found an API key or other secret in the commits you tried to push and blocked the whole push so the secret wouldn’t land in the repository.

Build with an agent that checks its work

The Layerwise agent clicks through the live preview and reads the console, so it catches errors before you do.