方法一:

项目根目录下新建 .gitignore 文件(详细参考:https://www.cnblogs.com/youyoui/p/8337147.html)

1
2
3
4
/target/*
/.idea/*
/src/test/*
*.iml

1
2
3
4
# .gitignore 规则不生效
git rm -r --cached .
git add .
git commit -m 'update .gitignore'

方法二:

新建一个 ChangeList,并把不需要提交的目录或文件拖进去


把不需要提交的目录或文件拖到 ignore 目录

提交的时候选择要提交的目录