Git this-operation-must-be-run-in-a-work-tree The command ran inside a bare repository or a Git directory, where no checkout exists.

dev@local: ~/project — git
dev@local~/project$git status
error: this operation must be run in a work tree
Diagnostics Translation
The command ran inside a bare repository or a Git directory, where no checkout exists.
waiting for resolution...
LowVersion Control System

Reviewed for reference consistency: August 11, 2026

Code is Safe

SECURE

Git has paused the operation to protect your code. No data has been lost or corrupted.

What To Know

This message means Git found a valid repository but no checkout attached to it, which is normal for bare clones and for sessions sitting inside the .git directory.

Where Did It Fail?

Working Tree
Your local files
add
Staging Index
Prepared changes
commit
Local Repo
Commit history
push/fetch
Remote Server
GitHub/GitLab
Git halted to protect the uncommitted files in your active working directory.

Commands That Trigger This

$git status
Running after cd .git inside a normal repository
Executing worktree commands in a server-side bare clone used only for pushes
A shell session left inside .git after searching through config or hooks

Technical Background

01

Bare repositories are deliberate: servers and shared upstreams store history without any checkout, because nobody edits files there directly. The message is Git noticing that the requested command belongs to the file-side half of that split.

02

Nothing is wrong with the repository itself. History, branches, and objects are all intact; the command simply has no checked-out files to operate on. Commands that work purely on history — log, show, fetch — usually succeed from the same directory.

Underlying Causes

The repository was created with `git init --bare` or `git clone --bare` and has no checkout
The working directory is a `.git` folder rather than the project root
core.bare is set to true on a directory that was expected to hold files
A script changed directories into the repository internals before invoking Git

Frequently Asked Questions

A bare repository contains a HEAD file, objects, and refs at its top level, while a broken checkout would be missing the whole .git directory; `git rev-parse --is-bare-repository` answers directly.

Yes. Receiving pushes is exactly what bare repositories exist for; only commands that need a working tree are unavailable.

Related Git States