下午在搞代碼部署的時候, 遇到一個文件大小寫的問題, 問題比較簡單, 可是也簡單整理下, 分享給你們。html
下午在搞代碼部署的時候, 線上編譯失敗了, 看了下錯誤日誌:webpack
#7 0.984 $ BABEL\_ENV=production webpack --config webpack/webpack.config.prod.js --colors #7 19.58 ModuleNotFoundError: Module not found: Error: Can't resolve './UserModal' in '/workspace/src/pages/User/UserList'
文件沒找到, 但是我看了看代碼, 這不是好好地在這嗎?git
到線上倉庫看了一下, 文件名是小寫的 userModal
。web
怪不得文件找不到。app
知道錯誤緣由就很好辦了。this
直接把git的忽略大小寫
關了:spa
git config core.ignorecase false
而後從新提交, 就OK了。3d
除去這個作法, 你也能夠這樣:日誌
git mv File file.tmp git mv file.tmp file
而後從新提交, 問題解決, 順利部署。code
下面咱們就看看這個ignorecase
:
在git官方文檔中, 相關描述以下:
Internal variable which enables various workarounds to enable Git to work better on filesystems that are not case sensitive, like APFS, HFS+, FAT, NTFS, etc. For example, if a directory listing finds "makefile" when Git expects "Makefile", Git will assume it is really the same file, and continue to remember it as "Makefile".The default is
false
, exceptgit-clone(1)orgit-init(1)will probe and set core.ignoreCase true if appropriate when the repository is created.Git relies on the proper configuration of this variable for your operating and file system. Modifying this value may result in unexpected behavior.
大意是說, 忽略大小寫敏感是爲了在不一樣的文件系統上更好的工做。
好比APFS,HFS +,FAT,NTFS
等。
例如,若是在目錄列表裏, Git指望找到一個文件叫Makefile
,卻找到了makefile
,這時候,Git就假定它是同一文件,並繼續將其記住爲Makefile
。
這個值默認是false
, 除了git-clone
或git-init
。
用這兩個命令建立repository
的時候,core.ignoreCase
會被設置成true
.
這下就明白了。
平時不遇到實際的狀況, 不太容易能注意到這點。
在這裏總結下, 但願看到的盆友能有個印象。
謝謝你們。