首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Git Diff命令中,100意味着什么?我知道这是Git文件模式,但请向我详细说明这个文件模式

在Git Diff命令中,100意味着什么?我知道这是Git文件模式,但请向我详细说明这个文件模式
EN

Stack Overflow用户
提问于 2022-03-30 04:54:01
回答 3查看 90关注 0票数 1

新的文件模式100644这个100在这里。我知道最后三个数字的意思。但这个文件模式并不意味着。请告诉我所有关于。我喜欢被充分告知。

我尝试搜索此文件模式,但我只获得有关文件权限的信息,而不是此文件模式。

EN

回答 3

Stack Overflow用户

发布于 2022-03-30 05:29:04

根据git文档

该代码是以八进制表示的一系列位,从最大到最小。

  1. 文件类型的4位
    • 1000 -常规文件
    • 1010 -符号链接
    • 1110 - git链接

  2. 3个未使用比特
  3. 权限的9位(仅为644或755 )

因此,您的100644示例转换为二进制

001 000 000 110 100 100

文件类型: 1000 -常规文件

未使用的比特数: 000

权限: 110 100 - 644

树似乎也得到没有权限的类型代码0100,尽管我没有在文档中看到这一点。

票数 2
EN

Stack Overflow用户

发布于 2022-03-30 06:06:10

Git树对象中的条目只能有五种不同的“文件模式”。例如,我当前的Git源代码包含了许多其他条目:

代码语言:javascript
运行
复制
040000 tree fe75d26ce528361a9ef3063415db408a7a1ca189    Documentation
120000 blob 81052262e0e43711f308ebc67a371def932cdccc    RelNotes
100755 blob 205541e0f7f81b1df4061215ae34a2742a45475d    generate-cmdlist.sh
100644 blob a25940d72e84e1ad6daba76a6c2845f320bc4df3    git.c
160000 commit 855827c583bc30645ba427885caa40c5b81764d2  sha1collisiondetection

这些模式是

  • 常规文件的100644
  • 可执行文件的100755
  • 子树(目录)的040000
  • 符号链接的120000
  • 子模块的160000

Git的作者本可以选择任何文本标记来识别这五种模式,但出于历史原因,他们选择将它们写成与C代码中的st_mode of a struct stat中的值相同的值,以八进制值形式编写。这种任意选择的证明是,160000值永远不会出现在struct stat中(这将是S_IFDIR|S_IFLNK,在行为良好的系统上是不可能的)。

票数 2
EN

Stack Overflow用户

发布于 2022-03-30 05:02:28

似乎filemode指的是可执行位(而不是所有权限)。

不建议使用core.fileMode。它只处理模式的可执行位,而不是读/写位。

根据吉特-康菲的文档

代码语言:javascript
运行
复制
core.fileMode
Tells Git if the executable bit of files in the working tree is to be honored.

Some filesystems lose the executable bit when a file that is marked as executable is checked out, or checks out a non-executable file with executable bit on. git-clone[1] or git-init[1] probe the filesystem to see if it handles the executable bit correctly and this variable is automatically set as necessary.

A repository, however, may be on a filesystem that handles the filemode correctly, and this variable is set to true when created, but later may be made accessible from another environment that loses the filemode (e.g. exporting ext4 via CIFS mount, visiting a Cygwin created repository with Git for Windows or Eclipse). In such a case it may be necessary to set this variable to false. See git-update-index[1].

The default is true (when core.filemode is not specified in the config file).
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71671690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档