.gitignore 规则不生效

364 阅读1分钟

想要忽略vue.config.js文件git的提交

image.png

问题:配置了 .gitignore 文件,但在 git add 的时候没有忽略掉。 有两种可能:

  1. .gitignore 文件配置有问题,比如我碰到过一次这个问题:我在 windows 系统下的 idea 中使用了 「Add to gitignore」 这个插件去添加需要被 ignore 的文件夹时候,它会在我的 .gitignore 文件中写入:.idea\ ,实际上应该是:/.idea/
  2. 在你添加新的 ignore 规则前,你曾经已经提交过这个规则对应的文件,这时候你需要先把本地缓存删除(改变成未 track 状态)使用指令:
git rm -r --cached . 
git add . 
git commit -m 'update .gitignore'
git push

使用后 忽略文件生效

作者:stonezhu
链接:juejin.cn/post/684490…
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。