Windows 的 .gitignore

适用于 Windows 的 13 条忽略规则,可直接复制到您的仓库。

Microsoft Windows 操作系统

Windows 的完整 .gitignore

# 由 LFGitignore - https://lfgitignore.com 生成
# 创建:2026-10-31 21:51:07 UTC
# 技术:Windows

### Windows ###
# Windows 缩略图缓存
Thumbs.db
# Windows 加密缩略图缓存
Thumbs.db:encryptable
# Windows 增强的缩略图缓存
ehthumbs.db
# Windows Vista 缩略图缓存
ehthumbs_vista.db
# Windows 故障转储
*.stackdump
# Windows 文件夹配置
[Dd]esktop.ini
# Windows 回收站
$RECYCLE.BIN/
# Windows 内阁档案
*.cab
# Windows 安装程序包
*.msi
# Windows 应用程序包
*.msix
# Windows 合并模块
*.msm
# Windows 补丁文件
*.msp
# Windows 快捷方式
*.lnk

这些 Windows 规则实际上忽略了什么

以下列出了每个忽略模式及其加入 .gitignore 的原因。

Windows 缩略图缓存文件

模式 忽略的内容
Thumbs.db Windows 缩略图缓存
Thumbs.db:encryptable Windows 加密缩略图缓存
ehthumbs.db Windows 增强的缩略图缓存
ehthumbs_vista.db Windows Vista 缩略图缓存

转储文件

模式 忽略的内容
*.stackdump Windows 故障转储

文件夹配置文件

模式 忽略的内容
[Dd]esktop.ini Windows 文件夹配置

文件共享上使用的回收站

模式 忽略的内容
$RECYCLE.BIN/ Windows 回收站

Windows 安装程序文件

模式 忽略的内容
*.cab Windows 内阁档案
*.msi Windows 安装程序包
*.msix Windows 应用程序包
*.msm Windows 合并模块
*.msp Windows 补丁文件

Windows 快捷键

模式 忽略的内容
*.lnk Windows 快捷方式

如何将此 .gitignore 用于 Windows

  1. 复制上面的Windows规则,或者直接下载文件。
  2. 在 Git 仓库根目录创建名为 .gitignore 的文件,并将规则粘贴进去。
  3. 如果其中一些文件已被跟踪,请运行 git rm -r --cached . 然后再次提交 - Git 仅将忽略规则应用于未跟踪的文件。
  4. 提交 .gitignore 以便团队中的每个人都共享相同的规则。

其他 操作系统 .gitignore 模板

查看每个 操作系统 模板