Tuesday, February 22, 2022

[SOLVED] can't add file to git repository but can change / commit

Issue

here is error :

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

error: .emacs: failed to insert into database
error: unable to index file .emacs
fatal: adding files failed

how can I fix it ? what's wrong with it ?


Solution

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

That is your problem. For some reason or another, Git is having trouble writing to .git/objects - typically this means it is owned by another user and doesn't have the proper permissions.

Try seeing what permissions the folder currently has by running ls -l .git/objects. Then, you can chmod or chown (or both) as necessary.



Answered By - Amber
Answer Checked By - Pedro (WPSolving Volunteer)