Windows 10 文件名大小写敏感设置

Linux 天然支持文件名大小写区分,同一目录下 abcABC 是两个独立的文件。Mac OS 也可以通过格式化时选择区分大小写的文件系统来实现。Windows 默认不支持,NTFS 虽然存储时保留大小写,但查找时始终不区分。

问题来源

在 Windows 上执行 git clone 克隆某个 Linux 内核相关仓库时,出现了下面的警告:

复制代码
warning: the following paths have collided (e.g. case-sensitive paths
on a case-insensitive filesystem) and only one from the same
colliding group is in the working tree:
  'include/uapi/linux/netfilter/xt_CONNMARK.h'
  'include/uapi/linux/netfilter/xt_connmark.h'
  'include/uapi/linux/netfilter/xt_DSCP.h'

原因很直接:仓库里同时存在大写和小写的同名文件,在"不区分大小写"的 Windows 文件系统上,后克隆的文件把先克隆的直接覆盖了,Git 检测到冲突就报了这个 warning。

解决方法

有两种方式可以解决:在 WSL2 终端里操作,或者用 fsutil.exe 给指定目录开启大小写敏感。

用管理员身份打开 cmd 或 PowerShell,切到 C:\Windows\System32,执行:

复制代码
fsutil.exe file SetCaseSensitiveInfo E:\github_code enable

成功的话会看到:

复制代码
PS C:\Windows\System32> fsutil.exe file SetCaseSensitiveInfo E:\github_code enable
已启用目录 E:\github_code 的区分大小写属性。

这个设置只对指定目录生效,不影响系统其他地方。

前提条件

以下四点缺一不可,否则命令会失败或报错:

  1. Windows 10 需要 1803(2018 年 4 月更新)或更高版本
  2. 已安装 WSL(Windows Subsystem for Linux)
  3. 目标目录所在分区为 NTFS 格式
  4. 以管理员身份运行终端
相关推荐
食指Shaye2 小时前
免费视频编辑软件FFmpeg 在windows上使用CMD命令行的操作说明
windows·ffmpeg
jason_renyu2 小时前
Windows 系统安装配置 MySQL 服务(含多端口/多实例管理)
windows·mysql·windows安装mysql·windows配置mysql·mysql多端口配置
娇娇yyyyyy2 小时前
QT编程(5):几种常用的对话框
windows·qt·microsoft
wsad05323 小时前
在Windows上创建Python虚拟环境并在PyCharm中使用
windows·python·pycharm
Yjing景3 小时前
windows关闭系统更新的方法
windows·暂停更新
封奚泽优3 小时前
Ollama模型文件默认存储位置与更改方法(Windows)
windows·ollama
袋子(PJ)3 小时前
Windows 下本地部署 Qwen3-0.6B:WSL2 + vLLM + Open WebUI 全流程
服务器·人工智能·windows
程序设计实验室16 小时前
在 Windows 11 上使用 Hyper-V 虚拟机准备安装OpenClaw
windows
唐宋元明清21882 天前
.NET Win32磁盘动态卷/跨区卷触发“函数不正确”问题排查
windows·c#·存储