linuxwindowsgitpermissionsgit-init

Where can I get the description of `--shared` option of `git init` command for Windows?


I am reading the Git documentation about the git init command:

--shared[=(false|true|umask|group|all|world|everybody|0xxx)]
Specify that the Git repository is to be shared amongst several users. This allows users belonging to the same group to push into that repository. When specified, the config variable "core.sharedRepository" is set so that files and directories under $GIT_DIR are created with the requested permissions. When not specified, Git will use permissions reported by umask(2).

The option can have the following values, defaulting to group if no value is given:

umask (or false)
Use permissions reported by umask(2). The default, when --shared is not specified.

group (or true)
Make the repository group-writable, (and g+sx, since the git group may be not the primary group of all users). This is used to loosen the permissions of an otherwise safe umask(2) value. Note that the umask still applies to the other permission bits (e.g. if umask is 0022, using group will not remove read privileges from other (non-group) users). See 0xxx for how to exactly specify the repository permissions.

all (or world or everybody)
Same as group, but make the repository readable by all users.

0xxx 0xxx
is an octal number and each file will have mode 0xxx. 0xxx will override users' umask(2) value (and not only loosen permissions as group and all does). 0640 will create a repository which is group-readable, but not group-writable or accessible to others. 0660 will create a repo that is readable and writable to the current user and group, but inaccessible to others.

This information is for Linux-based OS only. Am I right? But what about Windows? I use Git for Windows. Windows uses ACL instead of umask for working with permissions. :(


Solution

  • It is very sad, but umask and --shared do nothing in the Git Bash for Windows:

    Developer@BUSHCOMP MINGW64 /d/temp/000
    $ ls -l readme.txt
    -rw-r--r-- 1 Developer Domain users 0 Sep 10 16:44 readme.txt
    
    Developer@BUSHCOMP MINGW64 /d/temp/000
    $ chmod a+rw readme.txt
    
    Developer@BUSHCOMP MINGW64 /d/temp/000
    $ ls -l readme.txt
    -rw-r--r-- 1 Developer Domain users 0 Sep 10 16:44 readme.txt
    

    Permissions of the readme.txt wasn't changed: I see -rw-r--r-- instead of -rw-rw-rw-.

    Developer@BUSHCOMP MINGW64 /d/temp/000
    $ chmod 666 readme.txt
    
    Developer@BUSHCOMP MINGW64 /d/temp/000
    $ ls -l readme.txt
    -rw-r--r-- 1 Developer Domain users 0 Sep 10 16:44 readme.txt
    

    Permissions of the readme.txt wasn't changed again: I see -rw-r--r-- instead of -rw-rw-rw-.

    Ok, I try to use --shared=0666:

    Developer@BUSHCOMP MINGW64 /d/temp/000/111
    $ git init --shared=0666
    Bare repository is initialized Git в D:/temp/000/111/.git/
    
    Developer@BUSHCOMP MINGW64 /d/temp/000/111 (master)
    $ echo 2>test.txt
    
    
    Developer@BUSHCOMP MINGW64 /d/temp/000/111 (master)
    $ git add test.txt
    
    Developer@BUSHCOMP MINGW64 /d/temp/000/111 (master)
    $ git commit -m "Test"
    [master (root commit) 0d01d64] Test
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 test.txt
    
    Developer@BUSHCOMP MINGW64 /d/temp/000/111 (master)
    $ ls -l test.txt
    -rw-r--r-- 1 Developer Domain users 0 Sep 10 17:10 test.txt
    
    At this case I see `-rw-r--r--` instead of `-rw-rw-rw-` also.
    

    I've updated Git for Windows from 2.4.5 to 2.5.2 but these problems exist stil.

    UPD

    I got the answer here.