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

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

问题描述

当我从存储库中取出更改时,Git更改文件权限(实际上,他更改了组写入权限)。



如果我是正确的,那么Git应该只跟踪可执行文件位,并且无论如何都可以使用设置 core.filemode 为false。



但是,尽管filemode设置为false(在本地,全局和用户),但当我拉时, write 权限不断变化。 / p>

我可以使用git-hooks来重置正确的chmod,但这是一些开销,我宁愿如果有办法让git完全忽略文件模式改变。



任何人都知道如何做到这一点?

解决方案

核心 .sharedRepository ,发表在博客文章在协作仓库中保留Git对象上的组写入


解决方案结果相当简单。 >
在文件 .git / config 中,我添加了一行: sharedRepository = group ,就像这样:

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

此后,新文件在 .git / objects 中创建了具有适当的组写入权限。

(但是,请注意,新文件是由主要组通过其接收推送的用户账户的数量。如果在项目上合作的用户具有不同的主要群组,并且这些用户不共享该群组中的成员资格,那么您可能仍会遇到问题。)


确保您的 umask 值:


示例: 0660 将使所有者和组的回购可读写,但其他人不可访问(相当于组,除非<$


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

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

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

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.

Anyone know how to achieve this ?

解决方案

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":

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

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.)

Make sure of the value of your umask:

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天全站免登陆