Error pushing to GitHub - insufficient permission for adding an object to repository database

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.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 1.37 KiB, done.
Total 5 (delta 2), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects

fatal: failed to write object
error: unpack-objects exited with error code 128
error: unpack failed: unpack-objects abnormal exit
To [email protected]:bixo/bixo.git
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to '[email protected]:bixo/bixo.git'
  • After a clean clone from GitHub, I can edit/add/commit/push a modified file.
  • If I then repeat this a second time I get the above error.
  • I can push to other GitHub repositories just fine.
  • I've checked file/directory permissions on my side, and they seem OK.
  • I'm running git 1.6.2.3 on Mac OS X 10.5.8

The above repository was the source of my fun for a previous Stack Overflow question (SO 1904860), so maybe the GitHub repo got corrupted. The only similar issue I've found via searching was an unpack failed problem reported on github. Has anybody else run into this issue before, especially when not using GitHub?


Solution 1:

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.

Solution 2:

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: [email protected]: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.

Solution 3:

sudo chmod 777 -R .git/objects