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

前端 未结 13 950
小蘑菇
小蘑菇 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
      

提交回复
热议问题