简体   繁体   English

git diff 显示错误的文件模式 - 而不是 775 显示 755

[英]git diff displaying wrong file mode - instead of 775 displaying 755

I have recenlty changed system and few files started appearing in git diff.我最近更改了系统,并且很少有文件开始出现在 git diff 中。 Its due to mode change and am ok with that for now.它是由于模式更改而导致的,目前还可以。

I am wondering why git diff displaying mode 755, when it supposed to 775. In below screen all linux command says it is 775, but git diff says it is 755.我想知道为什么 git diff 显示模式 755,而它应该是 775。在下面的屏幕中,所有 linux 命令都说它是 775,但 git diff 说它是 755。

OS is Ubuntu 22.04.操作系统是 Ubuntu 22.04。

在此处输入图像描述

Git only stores one bit (as in binary digit) of "mode" information per ordinary file: "executable" ( +x ) or "not executable" ( -x ). Git 仅存储每个普通文件的“模式”信息的一位(如二进制数字):“可执行”( +x )或“不可执行”( -x )。 This single bit of mode information is, however, stored as mode 100755 ( +x ) or mode 100644 ( -x ).然而,这一单比特模式信息存储为mode 100755 ( +x ) 或mode 100644 ( -x )。

It's no coincidence that 100755 corresponds to a Linux 0755 file mode: in fact, the 100 part is from S_IFREG in <sys/stat.h> . 100755对应于 Linux 0755文件模式并非巧合:实际上, 100部分来自<sys/stat.h> S_IFREG Likewise 100644 corresponds to a file whose mode is 0644 or rw-r--r-- .同样100644对应于模式为0644rw-r--r--的文件。 In the distant past, Git did store more mode bits per file .在遥远的过去,Git 确实为每个文件存储了更多的模式位 But this was discovered to be a mistake, so now Git stores only the one mode bit—but uses the same encoding it used back when it stored more bits.但后来发现这是一个错误,所以现在 Git 只存储一个模式位,但使用它在存储更多位时使用的相同编码

The actual file permission bits that you'll find on disk will depend on your umask setting, not on the mode 100755 setting.您将在磁盘上找到的实际文件权限位取决于您的umask设置,而不是mode 100755设置。 If you have umask 022 , Git will create executable files with mode 0755 or rwxr-xr-x .如果你有umask 022 ,Git 将创建模式为 0755 或rwxr-xr-x可执行文件。 If you change your umask to 002 , Git will create such files with mode 0775 or rwxrwxr-x .如果您将 umask 更改为002 ,Git 将使用 0775 或rwxrwxr-x模式创建此类文件。 But the old and/or new mode as shown in git diff output will always be either 100644 or 100755 , and that means -x or +x respectively.但是git diff输出中显示的旧模式和/或新mode将始终为100644100755 ,这分别表示-x+x

When storing a file (blob) in Git, there are only two possible file modes: 644 or 755. That is, Git stores only the executable bit, and if it is set, it stores the latter, and if not, it stores the former.在 Git 中存储文件(blob)时,只有两种可能的文件模式:644 或 755。也就是说,Git 只存储可执行位,如果设置了,则存储后者,如果没有,则存储以前的。 Thus, for diffs, Git will only reflect whether the executable bit is set and will always use one of those two modes.因此,对于差异,Git 只会反映是否设置了可执行位,并将始终使用这两种模式之一。

In the working tree, Git uses the umask to set permissions, which explains why your files are actually 775.在工作树中,Git 使用 umask 设置权限,这就解释了为什么你的文件实际上是 775。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 git diff --numstat 通过字符串而不是文件路径 - git diff --numstat by strings instead of file paths 在 yocto 中将默认 rootfs 文件权限更改为 750 而不是 755 - Change default rootfs file permissions to 750 instead of 755 in yocto 如何查看文件上的git diff? - How to view the git diff on a file? laravel centOS 7 chmod 755/775 权限被拒绝“无法打开:无法打开流:权限被拒绝”,仅当我设置为 777 时才允许 - laravel centOS 7 chmod 755/775 permission denied"could not be opened: failed to open stream: Permission denied", only allows if I set to 777 如何将git .diff文件合并到源代码? - how to merge git .diff file to source code? 从 Git diff 文件计算更改行 - Calculating lines of change from a Git diff file 无法写入 Hadoop DFS 目录模式 775 组权限 UserGroupInformation - Cannot write to Hadoop DFS directory mode 775 group permission UserGroupInformation c命令system()的输出可以进入文件而不是在控制台上显示吗? - Can output from c command system() go into a file instead of displaying on the console? 使用 UMASK 创建具有 755 权限的 unix 文件 - Creating unix file with permission 755 with UMASK 为什么Linux上的Chrome显示错误的字体粗细? - Why is Chrome on Linux displaying the wrong font weight?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM