Git Push Error insufficient permission for adding an object to repository database
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
The error insufficient permission for adding an object to repository database means Git tried to write a new object and the filesystem or repository permissions blocked it. Even though it often appears during git push, the root cause is usually not the commit itself but who owns the repository storage and whether Git can write into its object database.
What Git Is Trying to Write
Before a push succeeds, Git packages commits, trees, and blobs as objects. In a normal working copy those objects live under .git/objects. In a bare repository on a server, they live in the repository directory itself.
So this error usually means one of two things:
- your local
.gitdirectory is not writable by your current user - the remote bare repository is not writable by the account receiving the push
That is why the message mentions the repository database. Git is talking about its object store, not your application database.
Diagnose the Local Repository First
In many cases, the problem comes from running Git commands once with sudo, extracting an archive as another user, or copying a repository in a way that changed ownership.
Check ownership and permissions locally:
If files under .git are owned by root or another account, Git may fail when it tries to create new object files or pack files.
For a repository that should belong entirely to your current user, the usual fix is:
That repair is appropriate for your own local clone. Do not apply it blindly inside shared repositories you do not administer.
If the Problem Is on the Remote Server
Sometimes the push reaches the server and then fails because the remote bare repository has bad ownership or group permissions. This is common on self-hosted Git servers, shared Unix accounts, or repositories stored on mounted volumes.
An administrator would typically inspect the bare repository like this:
If multiple users are meant to push to the same repository, the fix is usually group-based ownership plus shared write permissions:
The setgid bit on directories helps new files inherit the correct group, which prevents the same problem from coming back on the next push.
Distinguish Filesystem Problems from Auth Problems
This message is often confused with plain authentication failures. They are not the same.
- If GitHub rejects your credentials, you usually see an access denied message.
- If a filesystem rejects writes to
objects, you usually see this repository-database wording.
That distinction matters because changing SSH keys will not fix a local .git/objects ownership problem, and chown will not fix missing push permission on a hosted Git service.
A quick remote sanity check is still useful:
If authentication succeeds but the error still points at object creation, focus on repository storage permissions.
Preventing the Error
The safest habits are simple:
- avoid running
gitwithsudoin normal working copies - keep shared bare repositories configured with a shared group
- make sure CI jobs and deployment users do not rewrite repository ownership unexpectedly
- be careful when moving repositories across disks, containers, or network shares
Git is very tolerant of many workflow mistakes, but it is not tolerant of an unwritable object store.
Common Pitfalls
- Fixing the working tree files while forgetting that the real problem is under
.git. - Using
sudo git commitonce, then being surprised that future non-sudo pushes fail. - Assuming the problem must be with GitHub or GitLab credentials when the message is actually about disk permissions.
- Applying
chown -Ron a shared repository without understanding who else uses it. - Ignoring underlying storage issues such as full disks, quotas, or awkward NFS permission mapping.
Summary
- The error means Git cannot write to its object database.
- Check local
.gitownership first, especially.git/objects. - On self-hosted remotes, inspect the bare repository and shared group permissions.
- Do not confuse filesystem permission failures with authentication failures.
- Avoid
sudo gitin normal repositories unless you deliberately want root-owned Git metadata.
Related reading
- Given an RGB value what would be the best way to find the closest match in the database?
- Global setting for AsNoTracking?
- GO statements blowing up sql execution in .NET
- Good approach to switch database for Test mode / Sand box mode Rails 6
- Git push error ''[remote rejected] master -> master (branch is currently checked out)''
- Git push error 'remote rejected master - master branch is currently checked out
- Git Push ERROR Repository not found
- git push fails RPC failed; result22, HTTP code 411

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.