git: can't push (unpacker error) related to permission issues

前端 未结 13 912
小蘑菇
小蘑菇 2020-12-07 20:06

I have this problem when i try to push in git:

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

fatal: failed to write o         


        
相关标签:
13条回答
  • 2020-12-07 20:48

    Where I work we have been using this method on all of our repositories for a few years without any problems (except when we create a new repository and forget to set it up this way):

    1. Set 'sharedRepository = true' in the config file's '[core]' section.
    2. Change the group id of the repository to a group shared by all users who are allowed to push to it:

      chgrp -R shared_group /git/our_repos
      chmod -R g+w /git/our_repos
      
    3. Set the setgid bit on all directories in the repository so that new files/directories keep the same group:

      find /git/our_repos -type d -exec chmod g+s {} +
      
    4. Add this line to the pre-receive hook in the repository to ensure new file permissions allow group read/write:

      umask 007
      
    0 讨论(0)
  • 2020-12-07 20:48

    For me its a permissions issue:

    On the git server run this command on the repo directory

    sudo chmod -R 777 theDirectory/
    
    0 讨论(0)
  • 2020-12-07 20:49

    For me, this error occurred when I was out of space on my remote.

    I just needed to read the rest of the error message:

    error: file write error (No space left on device)
    fatal: unable to write sha1 file
    error: unpack failed: unpack-objects abnormal exit
    
    0 讨论(0)
  • 2020-12-07 20:49

    I was having trouble with this too, thinking my remote gitolite-admin was corrupted or something wrong.

    My setup is Mac OS X (10.6.6) laptop with remote Ubuntu 10 server with gitolite.

    It turned out that the problem was with my local checkout of gitolite-admin.

    Despite the "unpack failed" error, it turned out the the problem was local.

    I figured this out by checking it out again as gitolite-admin2, making a change, and the pushing.

    Voila! It worked!

    0 讨论(0)
  • 2020-12-07 20:52

    For what it worth, I had the same problem over my own VPS and it was caused by my low hard disk space on VPS. Confirmed by df -h command and after i cleaned up my VPS' hard disk; the problem was gone.

    Cheers.

    0 讨论(0)
  • 2020-12-07 20:53

    I use gitosis for managing this kind of stuff. Gitosis has a single user (usually called "git") that owns all the repositories, and it uses public-key-based access control to each repo. It might not suit your setup but is probably worth checking out (no pun intended).

    0 讨论(0)
提交回复
热议问题