什么是 git 的“文件模式”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19620335/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:12:39  来源:igfitidea点击:

What is git's "filemode"?

gitfilesystemsrepositorysettingsconfig

提问by Alex Gray

For something that exists in EVERY single gitrepo... on earth... there sure isn't very much info out there regarding filemode. The first 100 responses from google were all over the place, and a question with this' title handn't been asked.. so here goes.. What is filemode? For me, it's in every repo's ./git/configfile, near the top, a lá...

对于存在于每个单一git仓库中的东西......在地球上......肯定没有太多关于filemode. 来自 google 的前 100 个回复到处都是,没有人问过这个标题的问题..所以这里是..什么filemode?对我来说,它在每个 repo 的./git/config文件中,靠近顶部,一个 lá...

 [core]
    filemode = true

What is it? What does it mean? Does it bear any relation to

它是什么?这是什么意思?是否与

    bare = false

which I also don't really get... I use gitlike a madman, and know what a million otherof git's endless, and IMHO, arbitrarily concocted / half-brainedconfigparameters do.. but not this one... I'm sure it's a simple thing (maybe related to permissions? or war triggers a change flag?), so if you know more about how to manipulate the setting / and to what effect.. that would be good to know...

我也没有真正明白......我git像疯子一样使用,并且知道git 无穷无尽的其他一百万个,恕我直言,任意炮制/半脑config参数的作用......但不是这个......我是确定这是一件简单的事情(可能与权限有关?或War会触发更改标志?),所以如果您了解更多有关如何操作设置/以及产生什么效果的信息......那会很高兴知道......

回答by VonC

A git bare repo (detailed here) has no relation with filemode.
It is used for pushing to it, because since it has no working tree, there is no concern about maintaining said working tree in sync with what you just pushed.

一个 git 裸仓库(这里详细说明)与文件模式没有关系。
它用于推送到它,因为它没有工作树,因此不必担心保持所述工作树与您刚刚推送的内容同步。

what is a "fake" file? and what constitutes a "working" directory?

什么是“假”文件?什么构成“工作”目录?

There is no "fake" file. It is just that a bare repo only contains git's administrative and control files, not actual data file you could work with and modify.
Those are checked out in a "working directory", when the repo is not bare.

没有“假”文件。只是一个裸仓库只包含 git 的管理和控制文件,而不是您可以使用和修改的实际数据文件。
当 repo 不是空的时,它们会在“工作目录”中检出。

The git configman page

git config手册页

core.fileMode

If false, the executable bit differences between the index and the working tree are ignored; useful on broken filesystems like FAT (File Allocation Table).
See git-update-index.

The command honors core.filemodeconfiguration variable.
If your repository is on a filesystem whose executable bits are unreliable, this should be set to false.
This causes the command to ignore differences in file modes recorded in the index and the file mode on the filesystem if they differ only on executable bit.
On such an unfortunate filesystem, you may need to use git update-index --chmod=.

For me, it's in every repo's ./git/configfile, near the top,

如果为 false,则忽略索引和工作树之间的可执行位差异;在损坏的文件系统上很有用,比如FAT(文件分配表)
git-update-index

该命令遵循core.filemode配置变量。
如果您的存储库位于可执行位不可靠的文件系统上,则应将其设置为false.
这会导致命令忽略索引中记录的文件模式和文件系统上的文件模式之间的差异(如果它们仅在可执行位上有所不同)
在这样一个不幸的文件系统上,您可能需要使用git update-index --chmod=.

对我来说,它在每个 repo 的./git/config文件中,靠近顶部,

Me too, but on Windows, it is always:

我也是,但在 Windows 上,它总是:

git config --local core.filemode
false

Don't forget that git only records two filemodes:

不要忘记 git 只记录两种文件模式:

  • 644
  • 755
  • 644
  • 755

回答by cforbish

filemodeset true means file mode permission changes are considered changes.

filemodeset true 表示文件模式权限更改被视为更改。

bareset true means the directory is not a working directory (no real files).

bareset true 表示该目录不是工作目录(没有实际文件)。