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

**Code:** `error: insufficient permission for adding an object to repository database` · **Category:** Git · **Seen on:** Git, Linux

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/git/insufficient-permission-adding-object)
