從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
就恢復正常了。