在 Git / Gitolite 中设置 umask
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7086325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting umask in Git / Gitolite
提问by user852091
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?
我已经设置了 Git 和 Gitolite,在某些时候我记得在其中一个配置文件中看到过“umask”设置。这是否为我使用 Git 同步的所有文件设置了权限?这正是我所需要的。我在哪里可以找到它?
回答by VonC
The umask settings in Gitoliteare there for changing the umask for newly created repos (and not about the files managed in versions by those repos).
See gitolite.rc doc:
Gitolite中的umask 设置用于更改新创建的存储库的 umask(而不是关于这些存储库在版本中管理的文件)。
参见gitolite.rc 文档:
$REPO_UMASK
, octal, default 0077The default
UMASK
that gitolite uses makes all the repos and their contents haverwx------
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 bechmod -R g+rX
). This is becauseumask
only affects permissions on newly created files, not existing ones.
$REPO_UMASK
, 八进制, 默认 0077
UMASK
gitolite 使用的默认设置使所有存储库及其内容都具有rwx------
权限。想要运行 gitweb 的人意识到这行不通。处理这个问题的正确方法是给这个变量一个类似的值
0027
(注意语法:前导 0 是必需的),然后让运行网络服务器的用户(apachewww-data
,等等)成为 'git' 组的成员。如果您已经安装了 gitolite,则必须手动修复现有文件(对于 umask 或
0027
,那就是chmod -R g+rX
)。这是因为umask
只影响新创建文件的权限,而不影响现有文件的权限。
This settings is similar to the one use when you create directly a git repo (without gitolite):
此设置类似于直接创建 git 存储库(不带 gitolite)时的一种用法:
core.sharedRepository
When
group
(ortrue
), the repository is made shareable between several users in a group (making sure all the files and objects are group-writable).
Whenall
(orworld
oreverybody
), the repository will be readable by all users, additionally to beinggroup-shareable
.
Whenumask
(orfalse
), git will use permissions reported byumask
.
当
group
(或true
) 时,存储库可在组中的多个用户之间共享(确保所有文件和对象都是组可写的)。
当all
(orworld
oreverybody
) 时,除了是group-shareable
.
当umask
(或false
) 时,git 将使用umask
.
See also "How do I share a Git repository with multiple users on a machine?" for more.
另请参阅“如何在一台机器上与多个用户共享 Git 存储库?”了解更多信息。
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
).
当平台之间在权限方面存在冲突时,您还可以选择“指示 git 忽略文件权限更改” ( git config core.fileMode false
)。
Update: This answer covers gitolite 2. With gitolite 3 the setting changed from $REPO_UMASK
to just $UMASK
.
更新:这个答案涵盖了 gitolite 2。对于 gitolite 3,设置从 更改$REPO_UMASK
为 just $UMASK
。