I\'m getting back an unusual error while trying to do a \"git push\" to my GitHub repository:
Counting objects: 8, done. Delta compression using 2 threads. Compre
I was getting this error because every time a user push some content, the group of the file changed to the user. And then if some other user tried to push into the repository, it caused permission error and the push was rejected. So one need to ask your sysadmin to change the settings of the repository so that group of any file in the repository is not changed for any push by any user.
To avoid such problem, please ensure that when you initialize your git repository, use the command "git init --shared=group".
user@M063:/var/www/html/app/.git/objects$ sudo chmod 777 -R .git/objects
user@M063:/var/www/html/app/.git/objects$ sudo chown -R user:user .git/objects/
This happened to me when I tried to git pull
. Some analysis showed that somebody had commited with root in the past, thereby creating some objects with root ownership in .git/objects
.
So I ran
cd <repo>
la .git/objects/
and that showed root
ownership for some objects (directories) like this:
user@host:/repo> la .git/objects/
total 540
drwxr-xr-x 135 user user 4096 Jun 16 16:29 .
drwxr-xr-x 8 user user 4096 Jun 16 16:33 ..
drwxr-xr-x 2 user user 4096 Mar 1 17:28 01
drwxr-xr-x 2 user user 4096 Mar 1 17:28 02
drwxr-xr-x 2 user user 4096 Jun 16 16:27 03
drwxr-xr-x 2 user user 4096 Mar 3 13:22 04
drwxr-xr-x 2 root root 4096 Jun 16 16:29 05
drwxr-xr-x 2 user user 4096 Jun 16 16:28 07
drwxr-xr-x 2 root root 4096 Jun 16 16:29 08
Then I ran
sudo chown -R user:user .git/objects/
and it worked!
I was replacing user with my real user, of course.
Since the error deals with permissions on the object folder, I did a chown directly on the objects folder and it worked for me.
Usually this problem is caused by wrong user and group permissions on your Git servers file-system. The git repository has to be owned by the user and also his group.
Example:
If your user is called "git", his group "gitgroup", and the location of the Git repo is: git@mygitserverxyz.com:path/to/repo.git
then do a:
sudo chown -R git:gitgroup path/to/repo.git/
This fixed the git insufficient permission error for me.
When you see this error outside of github, here's a remedy.
Got this from: http://mapopa.blogspot.com/2009/10/git-insufficient-permission-for-adding.html
ssh me@myserver
cd repository/.git
sudo chmod -R g+ws *
sudo chgrp -R mygroup *
git config core.sharedRepository true
After this the git daemon should use the group file permissions when writing to .git/objects.