Today, when I was pulling changes from a remote repository, the error busted out:
error: insufficient permission for adding an object to repository database .git/objects
The error message indicates the problem itself, current user does not have insufficient permission to add objects to .git/objects folder.
If you’re familiar with Linux ownership and permission, it’s so easy for you. In case of not, read the following topic, it’s really interesting though: Linux Ownership and Permissions
So, we need to grant permission to the folder. We have 2 approaches:
1. Change owner of the folder and its sub-folders to current user
$chown [current-user-name]:[group-name] .git/objects -R
In my case:
$chown ducfilan:root .git/objects -R
Note: current username can be gotten from:
2. Chmod the folder and its sub-folders to grant write permission to the current user
If you execute the below command, you will see your permission to the objects folder:
$ll .git | grep objects $ll .git/objects
If you faced with the mentioned problem, you will see that you don’t have permission to that folder. Depends on your decision, you can grant which permissions to the folder you want. Maybe:
$chmod 766 .git/objects -R
Now you are ready to pull it down.
P/s: Personally, I recommend the first approach, it’s a natural and secure way.