在 Git / Gitolite 中设置 umask

发布于 2024-11-29 16:25:39 字数 106 浏览 1 评论 0原文

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝戈者 2024-12-06 16:25:39

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

$REPO_UMASK,八进制,默认0077

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

处理这个问题的正确方法是给这个变量一个类似0027的值(注意语法:前导0是必需的),然后让用户运行web服务器(apache,< code>www-data,无论如何)“git”组的成员。

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

此设置类似于直接创建 git 存储库(不带 gitolite)时使用的设置:

core.sharedRepository

group(或true)时,存储库可在组中的多个用户之间共享(确保所有文件和对象都是组可写的)。< br>
all(或worldeverybody)时,所有用户都可以读取存储库,此外还可以组共享.
umask(或false)时,git将使用umask报告的权限。


另请参阅“我该如何与一台计算机上的多个用户共享 Git 存储库?”了解更多信息。

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

更新:此答案涵盖 gitolite 2。在 gitolite 3 中,设置从 $REPO_UMASK 更改为 $UMASK

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文