git file mode change

提交代码到仓库时,发现明明没有改动的文件提示有修改,而且是不少的文件都提示有修改。git

可是修改的添加行和删除行都是 0。web

因而 diff 一下。shell

$ git diff code.cspa

old mode 100755code

new mode 100644orm


原来是文件模式发生了变化。ci

想了下,多是别人从 Mac 上提交,我在 Win 上 pull 代码,致使文件模式发生了变化。it


到网上看了一下如何修改:io

git config core.filemode falsetable

也能够直接修改代码仓库 .git 目录里的 config 文件的 filemode (在 [core] 段中)字段,将其改成 false。


若是要全局修改的话,加 --global 选项:

git config --global core.filemode false


fileMode 的解释:

core.fileMode 

       If false, the executable bit differences between the index and the

       working copy are ignored; useful on broken filesystems like FAT.

       See git-update-index(1). True by default.

参考连接:

http://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes


顺便查了下这个文件模式 100644 是什么意思。

咱们常常见的是后三位,好比上面的 644,UNIX 里的文件模式记法。

在 shell 里 ls -l 时第一列就是。

那么前三位表明了什么呢?

经查,前三位表明了文件类型。100 是普通文件的意思。

其它的常见类型以下所示:

    0100000000000000 (040000): Directory

    1000000110100100 (100644): Regular non-executable file

    1000000110110100 (100664): Regular non-executable group-writeable file

    1000000111101101 (100755): Regular executable file

    1010000000000000 (120000): Symbolic link

    1110000000000000 (160000): Gitlink

更详细的状况请参考下面的连接:

How to read the mode field of git-ls-tree's output 

http://stackoverflow.com/questions/737673/how-to-read-the-mode-field-of-git-ls-trees-output

相关文章
相关标签/搜索