I have git error: \"insufficient permission for adding an object to repository database .git/objects\" every time I make \"git pull origin develop\".
remote:
Assuming @ChrisHayes is right about an accidental sudo, this should fix it. From inside your repository:
sudo chown -R $USER:$USER "$(git rev-parse --show-toplevel)/.git"
Update: for those of you getting the illegal group name
error, try this instead:
sudo chown -R $(id -u):$(id -g) "$(git rev-parse --show-toplevel)/.git"
remove .git from the url, if you are trying to clone a public repository from github.
example:
From: https://github.com/example/repository.git To: https://github.com/example/repository
NOT A GOOD PRACTICE (Just an alternative)
I am using Ubuntu and faced the same problem. To solve it, I simply switched user to root and I see no further error.
$su
password
Then,
$git pull origin master
Recommended way: CHANGE THE PERMISSION OF THE DIRECTORY
Go to project's root directory and run below commands to fix this issue,
cd .git/objects
sudo chown -R yourname:yourgroup *
Mine was a stupid mistake... the right username and group were set, but www-data was the account accessing it. The directory was owned by vaindil:www-data, but permissions were 755 so www-data couldn't write to it. Fixed it with:
$ sudo chmod -R 775 /path/to/repo