在项目目录下创建 .gitignore 文件,里面的内容如下,可以根据自己的需要新增或者删除过来规则
# Local per-repo rules can be added to the .git/info/exclude file in your
# repo. These rules are not committed with the repo so they are not shared
# with others. This method can be used for locally-generated files that you
# don’t expect other users to generate, like files created by your editor.
.settings
.classpath
bin
coverage
coverage.ec
coverage.em
gen
javadoc
junit-report.xml
lint-results.*ml
lint-results_files
local.properties
monkey.txt
*~
*.iws
atlassian-ide-plugin.xml
target
build
.gradle
out
build.xml
proguard-project.txt
.idea/
*.iml
========================================================================
创建完上面的过滤文件后 需要执行以下方法才能生效:
改动过.gitignore文件之后,在repo的根目录下运行:
git rm -r --cached .
git add .
之后可以进行提交:
git commit -m "fixed untracked files"
如果执行上面方法不能生效,并且在创建上面文件之前已经提交代码到版本库了,那么这个时候可以尝试以下方法将想要过滤的相关文件,那么只能关掉开发工具,然后删除相关想要被过滤的文件。然后
git add -A
git commit -m "fixed untracked files"
git push origin master
git pull
此时打开开发工具即可实现想要的过滤效果了。