git关闭filemode


从Mac切换到Windows后,发现git有些文件是modified状态:

? git status
On branch main
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git restore ..." to discard changes in working directory)
        modified:   packages/src/pages/index.js

尝试将文件还原:

? git checkout packages/src/pages/index.js
Updated 1 path from the index
? git status
On branch main
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git restore ..." to discard changes in working directory)
        modified:   packages/src/pages/index.js

发现还原后还是显示modified,查看文件变化:

? git diff packages/src/pages/index.js
diff --git a/packages/src/pages/index.js b/packages/src/pages/index.js
old mode 100755
new mode 100644

发现文件的内容并没有变而是mode变了,关闭filemode:

git config core.filemode false

关闭后再 git status 就恢复正常了。