在您的项目根目录创建 .gitignore 文件
touch .gitignore
里面的过滤内容看您个人的需求,例如:
/data/cache/setting.php
/.idea
/data/config/config.ini.php
其中 * 代表所有,例:
/data/log/*.log(表示过滤掉 /data/log 目录下,所有以 .log 为后缀的文件)
GitHub 上相应的模板:
[https://github.com/github/gitignore](https://github.com/github/gitignore)
注意:.gitignore 只能忽略那些原来没有被纳入到仓库的文件,如果某些文件已经被纳入了版本管理中,则修改 .gitignore 是无效的。可以选择删除,然后 git push 再把删除的文件拉入项目中,这样就可以生效了。