git:无法索引文件 - 权限被拒绝 [英] git: Unable to index file - permission denied
问题描述
只有一个文件,我收到以下错误:
错误:无法写入sha1文件名/ opt / www /.git/objects/3f/ce3587c54a8be14c69b08c6b01f94949b11b47:权限被拒绝
错误:wp / wp-admin / css / theme-install.dev.css:未能插入数据库
致命:无法to index file wp / wp-admin / css / theme-install.dev.css
我检查了我的相关文件权限, .git 对象目录以及 .git 本身的权限。我可以添加除此之外的任何其他文件。我可以 stat / r / w / touch
这个文件,但是触摸没有帮助。 权限都是正确的。
这是一些疯狂的bug吗?
源代码(
sha1_file.c
,函数 move_temp_to_file()
)它看起来像Git无法重命名临时文件 /opt/www/.git/objects/3f/tmp_obj_XXXXXX
(其中 XXXXXX
是六个随机字符)至 /opt/www/.git/objects/3f/ce3587c54a8be14c69b08c6b01f94949b11b47
。如果您无权删除 /opt/www/.git/objects/3f
中的文件,则会发生这种情况。 $ b $如果有多个用户访问Git存储库,那么您可能需要运行一些类似于<$ c $的东西。 c> git config core.sharedRepository 0664 (详细信息请参阅
git help config
)以确保新创建的目录和文件对所有用户具有适当的权限。 rm -f /opt/www/.git/objects/3f/tmp_obj _ *
并查看是否这使问题消失。查看您是否可以通过执行以下操作来重现Git之外的问题:
mkdir -p /opt/www/.git/objects/3f
cd /opt/www/.git/objects/3f
rm -f tmp_obj_ * ce3587c54a8be14c69b08c6b01f94949b11b47
echotesting> tmp_obj_abcdefg
mv tmp_obj_abcdef ce3587c54a8be14c69b08c6b01f94949b11b47
rm -f tmp_obj_abcdefg
Be sur e运行上述命令的用户遇到错误。
chown
ing和 chmod
对象目录。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
, function move_temp_to_file()
) it looks like Git is failing to rename a temporary file named /opt/www/.git/objects/3f/tmp_obj_XXXXXX
(where XXXXXX
is 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:
- If multiple users accessing the Git repository, you may need to run something like
git config core.sharedRepository 0664
(seegit help config
for details) to ensure that newly created directories and files have proper permissions for all users of the repository. - Try running
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:
mkdir -p /opt/www/.git/objects/3f cd /opt/www/.git/objects/3f rm -f tmp_obj_* ce3587c54a8be14c69b08c6b01f94949b11b47 echo "testing" >tmp_obj_abcdefg mv tmp_obj_abcdef ce3587c54a8be14c69b08c6b01f94949b11b47 rm -f tmp_obj_abcdefg
Be sure to run the above commands the same user that experienced the error.
- Try recursively
chown
ing andchmod
ing the objects directory.
这篇关于git:无法索引文件 - 权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!