git 如何处理文件夹权限?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1071241/
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
How does git handle folder permission?
提问by hdorio
I'm using git version 1.5.6.3, and it seems git doesn't notice a folder's mode changes
我正在使用 git 版本 1.5.6.3,似乎 git 没有注意到文件夹的模式更改
#create a test repository with a folder with 777 mode
:~$ mkdir -p test/folder
:~$ touch test/folder/dummy.txt
:~$ cd test
:~/test$ chmod 777 folder/
#init git repository
:~/test$ git init
Initialized empty Git repository in ~/test/.git/
:~/test$ git add .
:~/test$ git commit -m 'commit a directory'
Created initial commit 9b6b21a: commit a directory
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 folder/dummy.txt
#change folder permission to 744
:~/test$ chmod 744 folder/
:~/test$ git status
# On branch master
nothing to commit (working directory clean)
What does 04000
stand for?
代表什么04000
?
:~/test$ git ls-tree HEAD folder
040000 tree 726c1d5f0155771348ea2daee6239791f1cd7731 folder
Is this normal behavior?
这是正常行为吗?
How can I track folder mode changes?
如何跟踪文件夹模式更改?
回答by CB Bailey
The only 'permissions' bit that git
tracks is the executable bit for files, the rest of the mode bits describe what type of file system object the object in each git tree is. git
supports files and symlinks (blobs), directories (trees) and the submodules (commits).
唯一git
跟踪的“权限”位是文件的可执行位,其余的模式位描述每个 git 树中的对象是什么类型的文件系统对象。git
支持文件和符号链接(blob)、目录(树)和子模块(提交)。
git
is designed to help track source code across different machines. Permission bits depend on user and group mappings between machines. In distributed environments where these mappings don't exist, tracking permission bits usually ends up hindering things rather than helping anything.
git
旨在帮助跟踪不同机器上的源代码。权限位取决于机器之间的用户和组映射。在这些映射不存在的分布式环境中,跟踪权限位通常最终会阻碍而不是帮助任何事情。
If you need to track more file system attributes that what git
tracks natively you could consider and extension tool such as etckeeper.
如果您需要git
跟踪本机跟踪的更多文件系统属性,您可以考虑使用扩展工具,例如etckeeper。