使用git的时候,经常init & push仓库以后,会把很多隐藏文件给push上去。尤其是.idea和*iml文件,还不能直接删,删了会导致工程出问题。
这个时候需要设置ignore文件。操作步骤如下:
$ cd /project/path
$ vim .gitignore
网上有很多写好的ignore文件可以参考:https://www.cnblogs.com/kevingrace/p/5690241.html,https://github.com/github/gitignore
我使用的是这个:
# Lines that start with '#' are comments.
# IntelliJ IDEA Project files
.idea
*.iml
*.ipr
*.iws
out
# Eclipse Project files
.classpath
.project
.settings/
bin/
gen/
local.properties
.DS_Store
Thumbs.db
*.bak
*.tem
*.temp
#.swp
*.*~
~*.*
$ git add .
$ git rm -r --cached .
可以看到需要被ignore的文件都被干掉了
$ git add .
$ git commit -a -m 'update ignore'
$ git push
$ git status
世界清净了。。。