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

相關文章
相關標籤/搜索