如何在Git提交大小写敏感的文件
背景
下午在搞代码部署的时候, 遇到一个文件大小写的问题, 问题比较简单, 但是也简单整理下, 分享给大家。
正文
下午在搞代码部署的时候, 线上编译失败了, 看了下错误日志:
#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'
文件没找到, 可是我看了看代码, 这不是好好地在这吗?
到线上仓库看了一下, 文件名是小写的 userModal
。
怪不得文件找不到。
知道错误原因就很好办了。
直接把git的忽略大小写
关了:
git config core.ignorecase false
然后重新提交, 就OK了。
除去这个做法, 你也可以这样:
git mv File file.tmp git mv file.tmp file
然后重新提交, 问题解决, 顺利部署。
ignorecase
下面我们就看看这个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
.
这下就明白了。
结尾
平时不遇到实际的情况, 不太容易能注意到这点。
在这里总结下, 希望看到的盆友能有个印象。
谢谢大家。
原文地址:https://segmentfault.com/a/1190000021847996
相关推荐
-
基于RabbitMQ解决微信大量并发回调的问题(微信产品服务端工程师值得看) javascript/jquery
2020-6-12
-
看完这几道 JavaScript 面试题,让你与考官对答如流(下) javascript/jquery
2020-5-19
-
找工作面试会遇到哪些坑(社招篇) javascript/jquery
2019-5-14
-
JS 中几种轻松处理’this’指向方式 javascript/jquery
2019-10-2
-
javascript 相关小的知识点集合 javascript/jquery
2019-9-13
-
axios中delete多样传参 javascript/jquery
2020-5-22
-
组件开发规范(vue) javascript/jquery
2020-6-12
-
JavaScript 实现方法重载 javascript/jquery
2020-5-28
-
element-ui的滚动条组件el-scrollbar(官方没有) javascript/jquery
2020-6-10
-
挑战大厂第1篇-树结构互转 javascript/jquery
2020-5-27