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

使用Strapi swagger插件时,如何让Git忽略/documentation下的所有JSON文件?

解决Git忽略Strapi documentation目录下JSON文件的问题
  • 修正.gitignore的规则写法
    之前的规则带空格导致Git无法正确识别路径,改成以下两种之一:

    • 只忽略documentation根目录下的JSON文件:
      documentation/*.json
      
    • 忽略documentation目录及其所有子目录下的JSON文件:
      documentation/**/*.json
      
  • 清理已缓存的JSON文件(如果之前提交过这些文件)
    如果这些JSON文件已经被Git追踪过,需要先从缓存中移除,执行以下命令:

    # 移除根目录下的JSON缓存
    git rm --cached documentation/*.json
    # 或者移除所有子目录下的JSON缓存
    git rm --cached documentation/**/*.json
    

    之后提交这个变更:

    git commit -m "不再追踪documentation目录下的JSON文件"
    
  • 验证效果
    修改内容触发文档重建后,执行git status,确认这些JSON文件不会出现在未跟踪文件列表中。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 23:52:01