git diff

1 取消 chmod 造成的文件权限

今天执行git diff filename ,出现
diff --git a/kernel/Documentation/ABI/testing/sysfs-driver-hid-roccat-kone b/kernel/Documentation/ABI/testing/sysfs-driver-hid-roccat-kone
old mode 100644
new mode 100755
但是发现文件内容并没有发生改变
想起来中间执行过chmod  的操作,
产生这个问题的原因就是:
filemode的变化,文件chmod后其文件某些位是改变了的,如果严格的比较原文件和chmod后的文件,两者是有区别的,但是源代码通常只关心文本内容,因此chmod产生的变化应该忽略,所以设置一下:
切到源码的根目录下,
git config --add core.filemode false
这样你的所有的git库都会忽略filemode变更了

对比两次commint

git diff com1 com2
结果为com2 和com1 对比 的增减

C
roc@roc-System-Product-Name:/home/workspace/rk3328-android7.1$ git log
commit f5c4ab3b7c17fe0ab94c1313ef1e439de5ca72e3 (HEAD -> master)
Author: flyfly 
Date:   Thu May 20 13:20:31 2021 +0800

    HX001 for huaxian ap,add serial port and permission, shell as daemon, shell for apcode self start

commit f56ab1c09fd3ef66303065287428ebe169649a7c
Author: rpdzkj <[email protected]>
Date:   Sat Jul 4 11:28:50 2020 +0800

    modify wifi sdio cd-gpio and compatible


git diff f5c4ab3b7c17fe0ab94c1313ef1e439de5ca72e3 f56ab1c09fd3ef66303065287428ebe169649a7c

你可能感兴趣的:(git diff)