Skip to content
Latchkey

GitHub Actions "fatal: not a git repository" after checkout path

git commands only work inside a checked-out worktree. When actions/checkout used a custom path, or no checkout ran in the job, the working directory has no .git and every git call fails.

What this error means

A git status, git describe, or git rev-parse step fails with "fatal: not a git repository" even though an earlier job checked out the code.

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

Common causes

No checkout in this job

Each job starts on a clean runner; a job that never runs actions/checkout has no repository on disk.

checkout used a non-default path

With path: set, the repo lives in a subdirectory, so git run from the default working-directory finds no .git.

How to fix it

Check out the repo where git runs

  1. Add actions/checkout to every job that needs the repository.
  2. If you set a custom path, run git steps with working-directory pointing at it.
  3. Do not assume artifacts or files persist across jobs without a checkout.
.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    path: src
- run: git rev-parse HEAD
  working-directory: src

How to prevent it

  • Add a checkout to each job that touches git.
  • Keep working-directory aligned with the checkout path input.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →