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

后端 未结 21 2220
孤街浪徒
孤街浪徒 2020-11-27 09:34

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         


        
21条回答
  •  不知归路
    2020-11-27 09:44

    After you add some stuff... commit them and after all finished push it! BANG!! Start all problems... As you should notice there are some differences in the way both new and existent projects were defined. If some other person tries to add/commit/push same files, or content (git keep both as same objects), we will face the following error:

    $ git push
    Counting objects: 31, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (17/17), done.
    Writing objects: 100% (21/21), 2.07 KiB | 0 bytes/s, done.
    Total 21 (delta 12), reused 0 (delta 0)
    remote: error: insufficient permission for adding an object to repository database ./objects  remote: fatal: failed to write object
    

    To solve this problem you have to have something in mind operational system's permissions system as you are restricted by it in this case. Tu understand better the problem, go ahead and check your git object's folder (.git/objects). You will probably see something like that:

    @ objects]$ ls -la
    total 200
    drwxr-xr-x 25   2048 Feb 10 09:28 .
    drwxr-xr-x  3   1024 Feb  3 15:06 ..
    drwxr-xr-x  2   1024 Jan 31 13:39 02
    drwxr-xr-x  2   1024 Feb  3 13:24 08
    

    *Note that those file's permissions were granted only for your users, no one will never can changed it... *

    Level       u   g   o
    Permission rwx r-x ---
    Binary     111 101 000
    Octal       7   5   0
    

    SOLVING THE PROBLEM

    If you have super user permission, you can go forward and change all permissions by yourself using the step two, in any-other case you will need to ask all users with objects created with their users, use the following command to know who they are:

    $ ls -la | awk '{print $3}' | sort -u 
    
    
    

    Now you and all file's owner users will have to change those files permission, doing:

    $ chmod -R 774 .
    

    After that you will need to add a new property that is equivalent to --shared=group done for the new repository, according to the documentation, this make the repository group-writable, do it executing:

    $ git config core.sharedRepository group
    

    https://coderwall.com/p/8b3ksg

提交回复
热议问题