Skip to content
Latchkey

git "insufficient permission for adding an object to repository database" in CI

git tried to write a new object into .git/objects and the OS denied it. The workspace (or its .git/objects) is owned by a different user than the one running git, common when a container step wrote files as root and a later step runs as the runner user.

What this error means

A fetch, commit, or checkout fails with "error: insufficient permission for adding an object to repository database .git/objects" followed by "fatal: failed to write object" or "unable to add ... to database".

git
error: insufficient permission for adding an object to repository database .git/objects
error: acme/shared: failed to insert into database
fatal: unable to write sha1 file

Common causes

Mixed ownership from a root container step

A container step wrote into the workspace as root; a later non-root step cannot write into .git/objects, so git fails on permission.

A reused self-hosted workspace with wrong ownership

Files left by a previous job under a different user leave .git/objects unwritable for the current runner user.

How to fix it

Restore ownership of the workspace

Chown the checkout back to the runner user so git can write objects.

Terminal
sudo chown -R "$(id -u):$(id -g)" "${{ github.workspace }}"

Clean the workspace and avoid root writes

  1. Let actions/checkout clean the workspace each run.
  2. Avoid writing into the checkout as root in earlier steps, or fix ownership after.
  3. On self-hosted runners, ensure jobs start from a consistent user.
.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    clean: true

How to prevent it

  • Keep workspace ownership consistent with the runner user.
  • Avoid writing into the checkout as root, or chown afterward.
  • Clean the workspace on reused self-hosted runners.

Related guides

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