10

I have git error: "insufficient permission for adding an object to repository database" every time I make "git push origin master".
I tried solution described here: http://parizek.com/2011/05/git-insufficient-permission-for-adding-an-object-to-repository-database-objects/ but it works only until next time...
Is there some permanent solution?

$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.19 KiB, done.
Total 3 (delta 2), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To ssh://user@git.code.sf.net/p/project/code
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh://user@git.code.sf.net/p/project/code'

$ git config core.sharedRepository true

$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.19 KiB, done.
Total 3 (delta 2), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To ssh://user@git.code.sf.net/p/project/code
 ! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh://user@git.code.sf.net/p/project/code'

$ sudo chmod -R g+ws *
$ sudo chgrp -R andrey *
$ git push origin master
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.19 KiB, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: <Repository /git/p/project/code.git> refresh queued.
To ssh://user@git.code.sf.net/p/project/code
   acd82d2..f401c90  master -> master

This is Ubuntu I use: 12.04.1, and git: 1.7.9.5

rodnower
  • 1,365
  • 3
  • 22
  • 30
  • 1
    Why are you doing this? Use github or gitorious or a solution which has already solved this problem. – Stefan Kendall Oct 07 '12 at 16:07
  • 1
    It possible use these tools if I store code in source forge? – rodnower Oct 09 '12 at 19:38
  • 2
    @Stefan Kendall: Perhaps the user is using a company-internal Git project, and he or his company does not want to move their code to an external service they have no control over? – Teemu Leisti Mar 17 '14 at 20:40

2 Answers2

7

That usually happens when someone commited to git while booing root. The .git/* files created in that process are protected from external change.

chmod -R 777 .git 

is a fast fix.

Zsolt Szilagyi
  • 4,741
  • 4
  • 28
  • 44
4

As mentioned in "Error pushing to GitHub - insufficient permission for adding an object to repository database", you need, in addition of the git config setting, to:

  • first set the umask for all your repos: umask 002 (so on your server side)
  • then set the git group to rw as mentioned in your solution, still on the server side.
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250