Skip to content
Latchkey

Git "destination path already exists and is not an empty directory"

Git refuses to clone into a directory that already has files in it. On a reused or self-hosted runner the previous job left a checkout behind, so the fresh clone has nowhere clean to land.

What this error means

A git clone step fails immediately with fatal: destination path 'repo' already exists and is not an empty directory. It happens on persistent/self-hosted runners that reuse the same workspace, not on ephemeral runners that start clean.

git clone output
fatal: destination path 'app' already exists and is not an empty directory.

Common causes

A leftover checkout from a previous job

Self-hosted or reused runners keep the working directory between jobs. A prior clone is still there, so the new clone target is non-empty and Git aborts.

A cache or artifact restored into the clone path

A cache restore or artifact download placed files at the same path the clone targets, leaving the directory dirty before the clone runs.

How to fix it

Clean the workspace before cloning

Remove or empty the target directory at the start of the job so the clone has a clean landing spot.

Terminal
rm -rf app
git clone https://github.com/org/app.git app

Reset an existing checkout instead of re-cloning

If you want to reuse the directory, fetch and hard-reset rather than cloning over it.

Terminal
cd app
git fetch origin
git reset --hard origin/main
git clean -ffdx

How to prevent it

  • Use ephemeral runners, or clean the workspace at job start on persistent ones.
  • Enable actions/checkout’s clean step (default) so the workspace resets each run.
  • Avoid restoring caches/artifacts into the repository checkout path.

Related guides

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