【问题标题】:Git repo default ignore files permissionsGit repo 默认忽略文件权限
【发布时间】:2016-11-13 22:04:57
【问题描述】:

前段时间,我参与了一个由几个人开发的项目。其中一个人有意或无意地更改了 chmod 一些文件。当更改推送到存储库时,每次都会从那里下载另一个代码,因为在开始时,许多文件被标记为“已更改”。我浪费了很多时间来寻找理由。

现在每次获取 repo 时,我都会在终端中写入

git config core.fileMode false

忽略更改文件权限。 我知道我可以在全局 git 配置文件中设置它,但我会做更多的事情。我想在项目存储库中将此选项设置为默认值,并且每个下载此存储库的人都将被设置为 git config 以忽略文件权限。

知道如何达到这个目标吗?

【问题讨论】:

    标签: git file-permissions chmod git-config


    【解决方案1】:

    Git 会忽略除可执行位之外的所有权限位 (换句话说,git 树对象的文件和目录条目具有 755 或 644 的权限掩码——仅此而已)。 core.fileMode 仅与可执行位有关。您通常希望尊重这些可执行位,但在某些奇怪的文件系统上除外,在这种情况下,用户应自行关闭 core.fileMode

    来自 git 帮助配置:

    core.fileMode 告诉 Git 是否遵循工作树中的可执行文件位。

           Some filesystems lose the executable bit when a file that is marked as executable is checked
           out, or checks out an 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).
    

    【讨论】:

      猜你喜欢
      • 2018-12-29
      • 2020-10-25
      • 2023-03-11
      • 2014-04-18
      • 1970-01-01
      • 1970-01-01
      • 2019-10-25
      • 2010-09-18
      相关资源
      最近更新 更多