error: insufficient permission for adding an object to repository database Git Origin: Build & delivery OSI layer 7 · Application Last updated 25 Nov 2026

error: insufficient permission for adding an object to repository database .git/objects

Some object files are owned by another user (often root).

Exact message you may see insufficient permission for adding an object to repository databaseerror: insufficient permission .git/objectserror: insufficient permission for adding an object to repository database .git/objects fatal: failed to write object
Seen on: Git Linux

Meaning

A previous sudo git made root-owned files. Fix with sudo chown -R $USER .git and avoid using sudo with Git.

Common causes

  • sudo git used earlier
  • Shared server with mixed users
  • Wrong umask/group

⚡ Quick fix

  1. sudo chown -R $USER:$USER .git
  2. Don't run git with sudo
  3. Use core.sharedRepository group for teams

Detailed fix by platform

Shell

  1. bash
    sudo chown -R "$USER" .git
    git config core.sharedRepository group

How to diagnose

  1. Owner — root?
  2. Users — shared?
  3. sudo — used?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Build & delivery. Errors that are often confused with or caused by this one (click to open):

./gradlew: Permission denied — bash: ./gradlew: Permission denied (Android)./gradlew: Permission…Azure DevOps: TF401019 / VS403 push rejected — remote: TF401027: You need the GenericContribute permission to perform this action. (Git)Azure DevOps: TF40101…bash: ./script.sh: Permission denied — bash: ./script.sh: Permission denied (Linux)bash: ./script.sh: Pe…Bitbucket: Branch permissions prevent push — remote: Branch permissions: You are not allowed to push to branch main (Git)Bitbucket: Branch per…chmod: changing permissions of 'x': Operation not permitted — chmod: changing permissions of '/mnt/data/file': Operation not permitted (Linux)chmod: changing permi…error: cannot update the ref 'HEAD': unable to append to logs — error: cannot update the ref 'HEAD': unable to append to '.git/logs/HEAD': Permission denied (Git)error: cannot update …error: inflate: data stream error / loose object is corrupt — error: inflate: data stream error (incorrect header check) error: unable to unpack header (Git)error: inflate: data …error: open("file"): Permission denied / unable to index file — error: open("data/db.sqlite"): Permission denied error: unable to index file 'data/db.sqlite' fatal: adding files failed (Git)error: open("file"): …error: in…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.