Only for one file, I am getting the following error:
error: unable to write sha1 filename /opt/www/.git/objects/3f/ce3587c54a8be14c69b08c6b01f94949b11b47: Permission denied
error: wp/wp-admin/css/theme-install.dev.css: failed to insert into database
fatal: unable to index file wp/wp-admin/css/theme-install.dev.css
I checked my permissions on the file in question, the .git objects directory in question, and .git itself. I can add any other files except for this one. I could stat/r/w/touch the file, and touching did not help. The permissions are all correct.
Is this some crazy bug?
Looking at the Git source code (
sha1_file.c, functionmove_temp_to_file()) it looks like Git is failing to rename a temporary file named/opt/www/.git/objects/3f/tmp_obj_XXXXXX(whereXXXXXXis six random characters) to/opt/www/.git/objects/3f/ce3587c54a8be14c69b08c6b01f94949b11b47. This can happen if you don’t have permission to delete files in/opt/www/.git/objects/3f.Some things to try:
git config core.sharedRepository 0664(seegit help configfor details) to ensure that newly created directories and files have proper permissions for all users of the repository.rm -f /opt/www/.git/objects/3f/tmp_obj_*and see if that makes the problem go away.See if you can reproduce the problem outside of Git by doing the following:
Be sure to run the above commands the same user that experienced the error.
chowning andchmoding the objects directory.