How to resolve Git error insufficient permission for adding an object to repository database
When working on a GitHub repo from different Linux hosts, I encountered an "insufficient permission" error when using git commands. Here is the solution that worked for me from StackOverflow.
Sections
The error
You’re working on a local version of a GitHub repo, and you use a command like git add .
or git pull
you are hit with this error:
insufficient permission for adding an object to repository database
Coming from only working with Git and GitHub from Windows, I first encountered this on Linux when I switched to Debian KDE desktop as my daily driver. My google searching took me to this thread on Stack Overflow where an explanation and solution for the error were provided.
The fix
This solution is credited to user Eric Leschinski in StackOverflow.
This error occurs because you accidentally committed a file or folder to git using elevated permissions and now git can’t modify those objects. It is safe to recursively force ownership of all files under .git/objects/
to your current user to clear the problem.
-
Make sure you’re inside the repository where you’re getting the error.
-
Get your username by typing
whoami
. -
Enter this command:
sudo chown -R your_user_name .git/*
. -
Proceed to use your git commands.