为什么我的文件权限在从git存储库中提取后发生更改 [英] why my file permission being changed after pull from git repository

查看:142
本文介绍了为什么我的文件权限在从git存储库中提取后发生更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一遍又一遍地遇到这个问题。我有一个在我的远程服务器上设置的git存储库,所有文件都设置为644,文件夹设置为755.但是,每次从git存储库(我使用bitbucket)提取后,我都注意到了我修改后的文件被更改为664,导致内部服务器错误。例如,我改变了index.php,当我尝试访问它时发生了500次。

I have been came across this problem over and over again. I have a git repository set up on my remote server and all the files are set to 644 and folders are set to 755. However, every time after i pulling from git repository(i'm using bitbucket), i noticed the permission of the file which i modified was changed into 664 which results a Internal server Error. For example, I changed the index.php, and it occurs 500 when i tried to get access to it

我必须使用
找到。 -type d -print0 | xargs -0 chmod 0755 find。 -type f -print0 | xargs -0 chmod 0644 手动将我的文件权限更改为正常

i have to use find . -type d -print0 | xargs -0 chmod 0755 and find . -type f -print0 | xargs -0 chmod 0644 to manually changed my files permission back to normal

推荐答案

将新文件夹/文件推送到共享库时Git将创建模式设置为100664:

As described in "Git set create mode to 100664 when pushing new folder/files to shared repo":


git不会以您想要的级别存储文件权限。拥有644或664个文件完全取决于 umask

022 在你的情况下,如>通过 Jan Hudec 发表评论

(022 in your case, as commented by Jan Hudec

Git只存储两个权限( 755 = rwxr.xr.x 644 = rw.r..r。 。
$ b

Git only stores two permissions (755=rwxr.xr.x, 644=rw.r..r..).


git根本不会追踪权限。

其实,它拒绝了,原来有足够的相互排斥的定义说明如何正确使用,所有这些都可以通过简单的脚本来完成,简单的脚本是实现它的正确方法。

此外,这些规则最好留在回购版中,因为存在回购目的和主机操作系统要考虑。

git simply doesn't track permissions.
In fact, it refuses to. Turns out there are enough mutually-exclusive definitions of how to do it right, all of which can be whipped up with simple scripting, that the simple scripting is the right way to implement it.
Plus, those rules are best left per-repo, because there's repo purpose and host OS to consider.

这篇关于为什么我的文件权限在从git存储库中提取后发生更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆