今天编辑 git 项目,拉下来后,发现很多文件都发生改动,但我并没有修改内容,查看 git diff
发现原来是权限变更了
diff --git a/.gitignore b/.gitignoreold mode 100644new mode 100755
可以如下解决
# 通过修改 git 配置,忽略文件模式的变更git config --global core.filemode false
其实之前也遇到过这个问题,我这里想深入了解一下,设置 644 还是 755,到底哪个更好呢?
644 rw-r--r--755 rwxr-xr-x语法为:chmod abc file其中a,b,c各为一个数字,分别表示User、Group、及Other的权限
755 比 644 多个执行权限(如果目录无执行权限,就无法列出文件列表)
最终解决方案如下:仅目录添加执行权限
# -x 删除执行权限,但也会失去无法列出文件的能力, 如 ls ./sudo chmod -R -x . # remove the executable bit from all files# +X 如果是目录,则为所有用户添加可执行标识chmod -R -x+X .
Explanation:
- -R - operate recursively
- -x - remove executable flags for all users
- +X - set executable flags for all users if it is a directory
参考:
