解决.gitignore文件无效问题

问题:有时候,我们修改.gitignore文件无效,如添加dist/,保存之后,修改dist文件夹内容发现还是会跟踪dist文件夹。

原因: git比较的是当前工作区与上一次commit的版本,之前版本是跟踪了dist文件夹的。

这里是一个.gitignore文件

.DS_Store

node_modules/

npm-debug.log*

yarn-debug.log*

yarn-error.log*

selenium-debug.log

dist/

Editor directories and files

.idea

.vscode

*.suo
.ntvs

*.njsproj

*.sln

解决办法:

git rm -r --cached dist

此命令 是把当前dist的跟踪记录删除,但是工作区中dist文件夹还是存在的。

然后

git add .

git commit -m"git忽略dist文件夹"

之后再修改dist文件就不跟踪了,因为这次提交已经把dist文件的跟踪删除。

相关推荐
7177776 小时前
双轨共存下的研发底座升级:Gitee 软件工厂迁移方法论
gitee
xiangzhihong81 天前
Android CLI 使用指南
gitee
大熊的瓜地3 天前
从0开始写launcher
gitee
choumou_M4 天前
SpringBoot_3在Gitee上创建远程仓库与协作开发教程
gitee
cakeism8255 天前
Gitee CodePecker:SCA+SAST双引擎驱动,从源头构筑DevSecOps研发安全防线
安全·gitee
老李要转行6 天前
【无标题】
gitee
7177776 天前
不止工具集成:基于 Gitee 软件工厂构建 DevSecOps 研发治理底座
java·服务器·gitee
7177776 天前
Gitee 推荐系统全链路解析:从项目筛选到 AI 智能协作
人工智能·gitee
Gavynlee6 天前
Git 操作问题排查与解决方案记录(Gitee 实战)
git·elasticsearch·gitee
7177777 天前
本土研发枢纽崛起:Gitee 企业版的价值跃迁
gitee