unnati patil unnati patil - 3 months ago 24
Git Question

Error while pull from git - insufficient permission for adding an object to repository database .git/objects

I have git error: "insufficient permission for adding an object to repository database .git/objects" every time I make "git pull origin develop".

remote: Counting objects: 70, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 42 (delta 35), reused 42 (delta 35)
error: insufficient permission for adding an object to repository database .git/objects

fatal: failed to write object
fatal: unpack-objects failed

Answer

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"