zoukankan      html  css  js  c++  java
  • git diff提示filemode发生改变(old mode 100644、new mode 10075)

    今天clone代码,git status显示修改了大量文件,git diff提示filemode变化,如下:

    diff --git a/Android.mk b/Android.mk
    old mode 100644
    new mode 100755

    原来是filemode的变化,文件chmod后其文件某些位是改变了的,如果严格的比较原文件和chmod后的文件,两者是有区别的,但是源代码通常只关心文本内容,因此chmod产生的变化应该忽略,所以设置一下:

    切到源码的根目录下,

    git config --add core.filemode false


    这样你的所有的git库都会忽略filemode变更了~

    补充:

    提交代码到仓库时,发现明明没有改动的文件提示有修改,并且是很多的文件都提示有修改。

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

    于是 diff 一下。

    $ git diff code.c
    
    old mode 100755
    
    new mode 100644

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

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

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

    git config core.filemode false

    也可以直接修改代码仓库 .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

    参考:https://www.cnblogs.com/sunzhenxing19860608/p/6066394.html

  • 相关阅读:
    在Vue-cli3.x中引入element-ui的新方式
    通过JS屏蔽鼠标右键
    java异常有效实践
    设计之禅——迭代器模式
    设计之禅——状态模式
    设计之禅——外观模式
    设计之禅——适配器模式
    设计之禅——我只要结果(命令模式)
    设计之禅——装饰者模式详解(与代理模式的区别以及与其他模式的组合)
    设计之禅——生成器模式
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15453029.html
Copyright © 2011-2022 走看看