How to fix the Git error: “fatal: this operation must be run in a work tree”

If you’ve tried running the command git status and are getting the following error, there is likely a very simple solution:

.git git:(dev) git status
fatal: this operation must be run in a work tree

The most common reason is that you are running the command in the .git folder, which isn’t part of the working tree. To solve this, move out of the .git folder: cd ..

Now run git status and you should get that actual status returned, a la:

example git:(dev) git status
On branch dev
Your branch is up to date with 'origin/dev'.

nothing to commit, working tree clean