git关闭filemode

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

❯ git status
On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." 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 <file>..." to update what will be committed)
  (use "git restore <file>..." 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 就恢复正常了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章