Git 在提交文件后,发现某些文件不用提交,这时只加上 .gitignore
不会起作用。
创建 .gitignore
# cp
/src/main/webapp/cp
删除缓存中已提交的文件
# git rm -r --cached <file>
git rm -r --cached /src/main/webapp/cp
提交
git commit -m "提交已忽略的文件"
常用配置
脚手架如 vite
https://start.spring.io/
甚至 idea
开发工具创建工程时,都会给出默认的 .gitignore
文件(一般使用脚手架创建的会更好一些)。
还有一个 gitignore 项目有大量的 .gitignore
示例,可以作为参考:https://github.com/github/gitignore