1、在项目跟路径下新建.ignore文件
2、在.ignore文件中配置要忽略的路径
/target/ .idea *.iml .tags .tags_sorted_by_file .pyc __pycache__ .cache .settings .classpath .project .DS_Store *.pid *Help target log.* .DS_Store log.home_IS_UNDEFINED doc/api_doc .class
3、一般这样做还不能生效,需要清一下缓存,在IDEA-Terminal端口输入:
git rm -r --cached .
如果报以下错误:
error: the following file has staged content different from both the
file and the HEAD:
.gitignore
(use -f to force removal)
则在命令中加入-f,注意不要忘了后面的".",意为清除所有文件。
git rm -r -f --cached .
清空之后在重新添加
git add .
之后更新gitignore
git git commit -m "update .gitignore"
此时再次提交,.ignore文件就生效了。



