我正在阅读 Git documentation关于 git init
命令:
--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.
此信息仅适用于基于 Linux 的操作系统。我对吗?但是 Windows 呢?我用 Git for Windows . Windows 使用 ACL 而不是 umask 来处理权限。 :(
最佳答案
很遗憾,umask
和 --shared
在 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
readme.txt 的权限未更改:我看到 -rw-r--r--
而不是 -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
readme.txt 的权限没有再次更改:我看到 -rw-r--r--
而不是 -rw-rw-rw-
。
好的,我尝试使用 --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.
我已经将 Git for Windows 从 2.4.5 更新到 2.5.2,但这些问题仍然存在。
UPD
我得到了答案 here .
关于linux - 我在哪里可以获得 Windows `--shared` 命令的 `git init` 选项的描述?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32496587/