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

Laravel项目中.gitignore配置忽略public/Customer目录无效如何解决?

解决Laravel中.gitignore配置/public/Customer/不生效的问题

如果已经在.gitignore里添加了/public/Customer/但规则不生效,大概率是这个目录(或其中的文件)已经被Git追踪过了——Git的.gitignore只对未被追踪的文件生效。

按以下步骤修复:

  • 先从Git索引中移除该目录的追踪(不会删除本地文件):
    git rm -r --cached public/Customer/
    
  • 确认.gitignore里的规则无误,路径/public/Customer/或public/Customer/都可以(前者是项目根目录相对路径,后者是相对当前.gitignore所在位置的路径,Laravel的.gitignore默认在根目录,所以两种写法都有效)
  • 提交修改:
    git add .gitignore
    git commit -m "不再追踪public/Customer目录"
    
  • 推送到远程仓库:
    git push
    

之后该目录下新增的文件都会被自动忽略,不会再被Git追踪。如果之后误操作又让该目录被追踪,重复上述步骤即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 20:39:28