zoukankan      html  css  js  c++  java
  • 如何在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

    然后重新提交, 问题解决, 顺利部署。

    vi设计http://www.maiqicn.com 办公资源网站大全https://www.wode007.com

    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.

    这下就明白了。

  • 相关阅读:
    产生sql语句的vba
    如何在IIS7或IIS7.5中导入导出站点及应用程序池. -摘自网络
    [js高手之路] es6系列教程
    [js高手之路] es6系列教程
    [js高手之路] es6系列教程
    [js高手之路] es6系列教程
    最通俗易懂的javascript变量提升
    [js高手之路] es6系列教程
    学生问的一道javascript面试题[来自腾讯]
    Java关键字final、static使用总结(转)
  • 原文地址:https://www.cnblogs.com/xiaonian8/p/13729784.html
Copyright © 2011-2022 走看看