Setting umask in Git / Gitolite

user852091 picture user852091 · Aug 17, 2011 · Viewed 10.2k times · Source

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?

Answer

VonC picture VonC · Aug 18, 2011

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.