git的相关问题以及解决方法

140 阅读1分钟

将文件写入.gitignore中不起作用,远程仓库仍然保有该文件

当已经向git远程仓库中添加过某个文件之后,再添加gitignore会失效,原因是因为缓存的问题,解决方案如下

1.清除缓存,命令如下

git rm --cached 路径
eg:
git rm --cached src/test/test.vue

2.提交

git commit -m ".gitignore修改"

3.推送

git push