You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git忽略a子目录下所有txt文件的问题排查及解决

Ignoring All TXT Files in Subdirectories of a/

If your directory structure looks like this:

a
|-- b
|   |-- qfq.txt
|   |-- ewfw.txt
|   | ...
|-- c
|   |-- wgfw.txt
|   |-- wjkh.txt
|   | ...
...

And you’re aiming to ignore every .txt file under all subdirectories of a/, here’s the breakdown of what works and why the initial confusion happened:

  • The rule /a/**/*.txt is actually valid and effective for your use case.
  • The reason you might have thought it wasn’t working is because Git doesn’t track or commit empty directories. Once all .txt files in subdirectories like b/ or c/ are ignored, those directories disappear from Git’s tracked files list—making it seem like the ignore rule failed, but it’s actually doing exactly what you want. Any new .txt files added to these subdirectories will be automatically ignored, and existing ones won’t show up in future commits.

Huge thanks to @JonathonReinhar, @phd, and pankaj for their quick and helpful responses that cleared up this confusion!

内容的提问来源于stack exchange,提问作者Somesh Jaiswal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 10:09:06