Git commit fails due to insufficient permissions

I get the following error when trying to commit to local storage:

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

I created another repository to compare permissions .git, .git/objectsand everything works fine in the new repository, and the permissions are the same as for drwxr-xr-x.

What could be causing this error?

+6
source share
4 answers
cd repository
chown -R user:group *
cd .git
chown -R user:group *
cd ..

there is a second chow because the first one did not make it into .git

Change: If the above does not help, try running the chown commands as root.

Edit 2: replace “user” and “group” with your username and group name.

+12
source

/ , /, : ?

+1

I ran into the same problem. I thought my current working local repository was corrupted. So, I again cloned the repository from the remote. Now I can commit and push from this new repository without any problems.

Note. If you want to change old repos, use git stash and apply git stash in the new repo.

0
source
cd <path-to-repo>
cd .git/objects
sudo chown -R <username>:<group> *

It worked for me from the staffband.

0
source

Source: https://habr.com/ru/post/1754448/


All Articles