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

**Code:** `not a git repository` · **Category:** Git · **Seen on:** Git, Docker

You ran a Git command outside a Git working tree.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/git/not-a-git-repository)
