一、清除git本地缓存
首先 .gitignore 只能忽略那些没有被追踪(track)的文件,且git存在本地缓存。
如果需要过滤文件之前已纳入了版本管理,那么除了修改ignore文件,还要清除本地缓存。
git rm -r --cached . git add . git commit -m "update .gitignore"
二、ignore文件模板
1. 后端
# compiled class file *.class # log file *.log *.imi *.lst # bluej files *.ctxt # mobile tools for java (j2me) .mtj.tmp/ # package files # *.jar *.war *.nar *.ear *.zip *.tar.gz *.rar # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* .idea *.iml out .settings/ .project .classpath /*/target/ logs/ .txlcn # ignore test file **/src/test/
2. 前端
.ds_store # node_modules 正常工作时需要过滤该文件 /dist # local env files .env.local .env.*.local # log files npm-debug.log* yarn-debug.log* yarn-eroor.log* pnpm-debug.log* # editor directories and files .idea .vscode *.suo *.ntvs* *.njsproj *.sln *.sw?
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论