在 Git/Gitolite 中设置 umask [英] Setting umask in Git / Gitolite

查看:21
本文介绍了在 Git/Gitolite 中设置 umask的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了 Git 和 Gitolite,在某些时候我记得在其中一个配置文件中看到过umask"设置.这是否为我使用 Git 同步的所有文件设置了权限?这正是我所需要的.我在哪里可以找到它?

解决方案

Gitolite 中的 umask 设置 用于更改新创建的存储库的 umask(而不是这些存储库在版本中管理的文件).
请参阅 gitolite.rc 文档:

<块引用>

$REPO_UMASK,八进制,默认 0077

gitolite 使用的默认 UMASK 使所有 repos 及其内容都具有 rwx------ 权限.想要运行 gitweb 的人意识到这行不通.

处理这个的正确方法是给这个变量一个像0027这样的值(注意语法:前导0是必需的),然后让用户运行网络服务器(apache,www-data,随便)'git' 组的成员.

如果您已经安装了 gitolite,则必须手动修复现有文件(对于 umask 或 0027,那就是 chmod -R g+rX).这是因为 umask 只影响新创建文件的权限,而不影响现有文件的权限.

这个设置类似于直接创建一个git repo(没有gitolite)时的使用:

core.sharedRepository

<块引用>

group(或 true)时,存储库可以在一个组中的多个用户之间共享(确保所有文件和对象都是组可写的).
all(或 worldeverybody)时,除了 group-shareable 之外,所有用户都可以读取存储库代码>.
umask(或false)时,git会使用umask上报的权限.

另见 "如何在一台机器上与多个用户共享 Git 存储库?"了解更多.

当您在平台之间存在与权限相关的冲突时,您还可以选择指示 git 忽略文件权限更改"(git config core.fileMode false).

更新:此答案涵盖 gitolite 2.使用 gitolite 3,设置从 $REPO_UMASK 更改为 $UMASK.

I have set up Git and Gitolite, and at some point I recall having seen an "umask" setting, in one of the configuration files. Does this set the permissions for all files I sync using Git? That is exactly what I need. Where can I find it?

解决方案

The umask settings in Gitolite are there for changing the umask for newly created repos (and not about the files managed in versions by those repos).
See gitolite.rc doc:

$REPO_UMASK, octal, default 0077

The default UMASK that gitolite uses makes all the repos and their contents have rwx------ permissions. People who want to run gitweb realise that this will not do.

The correct way to deal with this is to give this variable a value like 0027 (note the syntax: the leading 0 is required), and then make the user running the webserver (apache, www-data, whatever) a member of the 'git' group.

If you've already installed gitolite then existing files will have to be fixed up manually (for a umask or 0027, that would be chmod -R g+rX). This is because umask only affects permissions on newly created files, not existing ones.

This settings is similar to the one use when you create directly a git repo (without gitolite):

core.sharedRepository

When group (or true), the repository is made shareable between several users in a group (making sure all the files and objects are group-writable).
When all (or world or everybody), the repository will be readable by all users, additionally to being group-shareable.
When umask (or false), git will use permissions reported by umask.

See also "How do I share a Git repository with multiple users on a machine?" for more.

When you have conflicts between platforms relative to permissions, you also have the option to "instruct git to ignore file permissions changes" (git config core.fileMode false).

Update: This answer covers gitolite 2. With gitolite 3 the setting changed from $REPO_UMASK to just $UMASK.

这篇关于在 Git/Gitolite 中设置 umask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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