not a git repository 🌿 Git

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

You ran a Git command outside a Git working tree.

Seen on: Git Docker

Meaning

Git searches the current directory and parents for .git. Not finding it means you’re in the wrong folder, the repo was never initialized, or .git was deleted.

Common causes

  • Wrong current directory
  • Repo not cloned/initialized
  • CI/Docker build context excludes .git (.dockerignore)
  • Ownership mismatch (detected dubious ownership on newer Git)

⚡ Quick fix

  1. cd into the project folder
  2. git init or clone the repo
  3. In CI, ensure checkout step ran; in Docker, don’t rely on git inside the image

Detailed fix by platform

Git

  1. For “dubious ownership”: git config --global --add safe.directory /path/to/repo.

How to diagnose

  1. Directory — pwd — right folder?
  2. .git — Does it exist?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.