idea提交代码忽略iml,idea,classes,target等

 - 或者在项目根目录下创建.gitignore文件,并添加

/*.iml
/.idea/
/.gitignore

//.gitignore只能忽略那些原来没有被track(之前没有add过)的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的。
// 先把本地缓存删除(改变成未track状态),然后再提交:
//git rm -r --cached target
//git rm -r --cached .idea

报错加 -f

the following file has staged content different from both the
file and the HEAD:
.idea/.gitignore
(use -f to force removal)

//git rm -r -f --cached .idea

相关文章: