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

Linux 天然支持文件名大小写区分,同一目录下 abc 和 ABC 是两个独立的文件。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. 以管理员身份运行终端
相关推荐
the3clipse2 小时前
MPC-HC 下载安装与最佳配置教程:免费开源、轻量无广告、支持 4K 硬解的 Windows 播放器
windows·播放器·安装教程·硬件加速·mpc-hc·字幕设置·lav filters
独隅3 小时前
WebStorm Windows 版 React / Next.js 实战替换指南
javascript·windows·webstorm
陈工大模型3 小时前
2026年11月最新免费解压软件横评:7-Zip 、 Win解压缩名列前茅
windows·软件工程·7-zip·压缩软件
中二骚年1 天前
Windows 安全中心 / 防火墙故障,calc和Microsoft Store,终端(管理员)无法正常打开。 原因 + 修复方案
windows·安全·microsoft
万联WANFLOW1 天前
CVE-2026-98432 等漏洞自查:AI 查出的 Linux、Windows 漏洞,运维怎么确认受不受影响
linux·运维·windows·网络安全
AlanAshley1 天前
Windows 中导致延迟的软硬件及协议比重
windows
yuezhilangniao1 天前
win10中文 以及 PowerShell 开发日常
windows·powershell
共享家95272 天前
408 操作系统第一章
服务器·数据库·windows
Sakura_j_h_2 天前
GitHub Actions 打包 Windows exe:中文编码与产物上传
windows·ci/cd·打包发布·github·pyinstaller·github actions
xixiaoyunya2 天前
搭一个浏览器即用的二进制文件分发点:目录规范与权限边界实践
网络·windows