防止 Git 更改拉取权限 [英] Prevent Git from changing permissions on pull

查看:60
本文介绍了防止 Git 更改拉取权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从我的存储库中提取更改时,Git 更改了文件权限(实际上,他更改了组 write 权限).

When I pull change from my repositories, Git change the file permissions (actually, he change the group write permission).

如果我是对的,Git 应该只跟踪可执行位,无论如何都可以通过将 core.filemode 设置为 false 来删除.

If I'm correct, Git should only track executable bit and this anyway can be removed using setting core.filemode to false.

但是,虽然filemode设置为false(在本地,全局和用户),当我拉时,write权限不断变化.

But, although the filemode is set to false (in local, global and user), when I pull, write permission constantly change.

我可以使用 git-hooks 来重置正确的 chmod,但这是一些开销,如果有一种方法可以让 git 完全忽略文件模式更改,我更喜欢.

I could use a git-hooks in order to reset correct chmod, but this is some overhead and I'd prefer if there's a way to just ask git to completly ignore file mode change.

有人知道如何实现吗?

推荐答案

可能 在这里有帮助的一个配置设置是 core.sharedRepository,在博客文章在协作存储库中保存对 Git 对象的组写入":

One config setting that might help here is core.sharedRepository, presented in the blog post "Preserving Group Write on Git Objects in a Collaborative Repository":

结果证明解决方案相当简单.
在文件 .git/config 中,我添加了一行内容:sharedRepository = group",如下所示:

The solution turned out to be fairly straightforward.
In the file .git/config, I added a line that read: "sharedRepository = group", like so:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    sharedRepository = group

此后,.git/objects 中的新文件被创建,并具有适当的组写入权限.
(但是,请注意,新文件由接收推送的用户帐户的主要组拥有.如果在项目上协作的用户具有不同的主要组,并且如果这些用户不共享该组中的成员资格组,您可能仍然会遇到问题.)

Thereafter, new files in .git/objects were created with the proper permissions for group write.
(However, note that new files are group-owned by the primary group of the user account via which the push was received. If the users collaborating on the project have different primary groups, and if those users do not share membership in that set of groups, you may still run into problems.)

确保umask值:

Make sure of the value of your umask:

示例:0660 将使所有者和组可以读/写 repo,但其他人无法访问(等同于组,除非 umask 是例如 0022).

Example: 0660 will make the repo read/write-able for the owner and group, but inaccessible to others (equivalent to group unless umask is e.g. 0022).

这篇关于防止 Git 更改拉取权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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