Skip to main content

Git Repair Permissions


Git Push Error: insufficient permission for adding an object to repository database


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

After you have identified and fixed the underlying cause (see below), you’ll want to repair the permissions:


cd /path/to/repo.git
chgrp -R groupname .
chmod -R g+rwX .
find . -type d -exec chmod g+s '{}' +

Underlying Causes


The error could be caused by one of the following:
  • The repository isn’t configured to be a shared repository (see core.sharedRepository in git help config). If the output of:
  • git config core.sharedRepository
    
    is not group or true or 1 or some mask, try running:
    git config core.sharedRepository group
    
    and then re-run the recursive chmod and chgrp (see “Repair Permissions” above).
The operating system doesn’t interpret a setgid bit on directories as “all new files and subdirectories should inherit the group owner”.
When core.sharedRepository is true or group, Git relies on a feature of GNU operating systems (e.g., every Linux distribution) to ensure that newly created subdirectories are owned by the correct group (the group that all of the repository’s users are in). This feature is documented in the GNU coreutils documentation:
… [If] a directory’s set-group-ID bit is set, newly created subfiles inherit the same group as the directory, and newly created subdirectories inherit the set-group-ID bit of the parent directory. … [This mechanism lets] users share files more easily, by lessening the need to use chmodor chown to share new files.
However, not all operating systems have this feature (NetBSD is one example). For those operating systems, you should make sure that all of your Git users have the same default group. Alternatively, you can make the repository world-writable by running git config core.sharedRepository world (but be careful—this is less secure).
  • The file system doesn’t support the setgid bit (e.g., FAT). ext2, ext3, ext4 all support the setgid bit. As far as I know, the file systems that don’t support the setgid bit also don’t support the concept of group ownership so all files and directories will be owned by the same group anyway (which group is a mount option). In this case, make sure all Git users are in the group that owns all the files in the file system.
  • Not all of the Git users are in the same group that owns the repository directories. Make sure the group owner on the directories is correct and that all users are in that group.

Comments

Popular posts from this blog

Git: Remove Branches after Merge

After complete your task of a branch commit and push it. Then checkout to the main(normally master branch) Suppose your branch is   branch1  Then merge it git checkout master git merge branch1 After the merge, it's safe to delete the branch: git branch -d branch1 Additionally, git will warn you (and refuse to delete the branch) if it thinks you didn't fully merge it yet. If you forcefully delete a branch (with  git branch -D ) which is not completely merged yet, you have to do some tricks to get the unmerged commits back though (see below). There are some reasons to keep a branch around though. For example, if it's a feature branch, you may want to be able to do bugfixes on that feature still inside that branch. If you also want to delete the branch on a remote host, you can do: git push origin :branch1 This will forcefully delete the branch on the remote (this will not affect already checked-out repositiories though and won't prevent anyone with...

Download Files From Remote to local via command line

To download Files From Remote to local via command line  normally we use scp. To copy all from  Local Location  to  Remote Location  (Upload) scp - r / path / from / destination username@hostname :/ path / to / destination Copy on current directory from  Remote to Local scp - r username@hostname :/ path / from / file . To download a single file the command will be: scp user@your . server . example . com :/ path / to / foo/file.name / home / user / Desktop / To download a single file the command will be:  scp - r user@your . server . example . com :/ path / to / foo / home / user / Desktop / Help: -r  Recursively copy all directories and files Always use full location from  / , Get full location by  pwd scp  will replace all existing files hostname  will be hostname or IP address if custom port is needed (besides port 22) use  -P portnumber . (dot)  - it means current working directory...

Things you need to know about cron

cron is a Linux utility which schedules a command or script on your server to run automatically at a  specified  time and date.  They're most commonly used for automating system maintenance or administration. However, they are also relevant to web application development.   Why use cron?  Server admins have been using cron jobs for a long time.   You can expire and erase cached data files in a certain interval. You can auto-check your website content for broken links and have a report e-mailed to yourself regularly. Can update your database from external api  Syntax Here is a simple cron job: 1 10 * * * * /usr/bin/php /www/virtual/username/cron.php > /dev/null 2>&1 It consists of five parts: minute hour day of month month day of week Can generate the sequence from  crontab guru ,    https://crontab.guru/every-30-minutes Editing the Crontab Running this command wil...