Git Push error: insufficient permission to add object to repository database

When I try to push to the shared git remote, the following error occurs: insufficient permission for adding an object to repository database

Then I learned about a fix here: repair This applies to the next push because all files belong to the correct group, but the next time someone pushes a change, it creates a new item as a group in the object folder with the default group. The only thing I can think of is to change the default group for all projects that developers check in, but it seems like a hack. Any thoughts? Thank you.

#1 building

I had the same problem. As I read here, I realized that this is the file permission that the message refers to. For me, the solution is:

/etc/inetd.d/git-gpv

It starts git daemon as user "nobody" and therefore lacks write permission.

# Who   When    What
# GPV   20Nov13 Created this by hand while reading: http://linuxclues.blogspot.co.uk/2013/06>/git-daemon-ssh-create-repository-debian.html
# GPV   20Nov13 Changed owner (to user_git) otherise nobody lack permission to update the repository
#git stream tcp nowait nobody  /usr/bin/git git daemon --inetd --verbose --enable=receive-pack --export-all /gitrepo
git stream tcp nowait user_git  /usr/bin/git git daemon --inetd --verbose --enable=receive-pack --export-all /gitrepo

(I wonder if others call their inetd conf file git GPV. Usually it's directly in / etc/inetd.conf)

#2 building

After adding something... Submit them and finish all the push! Bang!! Start with all the questions... You should notice that there are different ways to define new and existing projects. If someone else tries to add / submit / push the same file or content (git keeps both objects the same), we 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 must keep in mind the permission system of the operating system, because it is limited in this case. Tu has a better understanding of the problem, please continue to check the git object's folder (. git / objects). You may see something similar:

<your user_name>@<the machine name> objects]$ ls -la
total 200
drwxr-xr-x 25 <your user_name> <group_name> 2048 Feb 10 09:28 .
drwxr-xr-x  3 <his user_name> <group_name> 1024 Feb  3 15:06 ..
drwxr-xr-x  2 <his user_name> <group_name> 1024 Jan 31 13:39 02
drwxr-xr-x  2 <his user_name> <group_name> 1024 Feb  3 13:24 08

*Please note that the permissions for these files are only granted to your users and no one can ever change it*

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

Solve the problem

If you have superuser rights, you can use the second step to continue to change all rights yourself. In any other case, you need to ask all users who have objects created with their users. Please use the following command to know who they are:

$ ls -la | awk '{print $3}' | sort -u 
<your user_name>
<his user_name>

You and the owner user of all files must now change the permissions for these files by:

$ chmod -R 774 .

After that, you will need to add a new attribute, which is equivalent to the -- shared = group completed for the new repository. According to the document, this makes the repository group writable. Do the following:

$ git config core.sharedRepository group

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

#3 building

This can easily happen if you run git init as a different user than the user who plans to push the change.

If you blindly follow the instructions on [1], it may be that you created git user as root and then immediately went to git init without changing the user in between.

[1] http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server

#4 building

You need to have sufficient write access to the directory to be pushed.

For me: Windows 2008 server

Right click the git repo directory or the parent directory.

Properties > share tab > Advanced share > permissions > make sure the user has the appropriate access rights.

#5 building

As far as I'm concerned, none of these suggestions worked. On Windows, this works for me:

  • Copy remote warehouse to another folder
  • Share folders and give appropriate permissions.
  • Make sure the folder is accessible from the local computer.
  • Add this warehouse as another remote warehouse in the local warehouse. ( git remote add foo //SERVERNAME/path/to/copied/git )
  • Push to foo. git push foo master . Did it work? Big! Now delete the repository that is not working properly and rename it to a previous version. Ensure that permissions and shared properties remain unchanged.

Tags: git Database Windows ssh

Posted on Wed, 08 Jan 2020 03:57:26 -0800 by zonkd