# fatal: This operation must be run in a work tree

- **ID:** `git/detached-head-from-bare-repo`
- **Domain:** git
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Attempting to run a command that requires a working tree (like checkout or status) inside a bare repository.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| git 2.43.0 | active | — | — |
| git 2.44.0 | active | — | — |
| git 2.45.0 | active | — | — |

## Workarounds

1. **Clone the bare repo into a working tree: git clone /path/to/bare.git /tmp/workdir && cd /tmp/workdir && git status** (95% success)
   ```
   Clone the bare repo into a working tree: git clone /path/to/bare.git /tmp/workdir && cd /tmp/workdir && git status
   ```
2. **Use 'git worktree add' to create a linked working tree from the bare repo: git worktree add /tmp/workdir main** (85% success)
   ```
   Use 'git worktree add' to create a linked working tree from the bare repo: git worktree add /tmp/workdir main
   ```

## Dead Ends

- **Running 'git checkout main' in a bare repo thinking it will switch branches** — Bare repos have no working tree; checkout cannot modify files (95% fail)
- **Setting GIT_DIR to a bare repo path and running git status** — Bare repos store only objects, no index or working tree for status (90% fail)
