开发者

Git commit fails due to insufficient permissions

开发者 https://www.devze.com 2023-01-07 16:26 出处:网络
I am getting the following error while trying to commit to a local repository: error: insufficient permission for adding an object to repository database .git/objects

I am getting the following error while trying to commit to a local repository:

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

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

What might be causing this error?开发者_开发百科


cd repository
chown -R user:group *
cd .git
chown -R user:group *
cd ..

the second chown is there because the first one didn't get into .git

Edit: If above does not help, try to run the chown commands as root.

Edit 2: replace 'user' and 'group' with your username and groupname.


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

This worked for me with group staff.


I have faced the same issue. I thought my current working local repository got corrupted. So I have cloned the repository from remote again. Now I'm able to do commit and push from this new repository without any issues.

Note: If you want your old repo changes then use git stash and do git stash apply in new repo.

0

精彩评论

暂无评论...
验证码 换一张
取 消