在項目目錄下建立 .gitignore 文件,裏面的內容以下,能夠根據本身的須要新增或者刪除過來規則java
# Local per-repo rules can be added to the .git/info/exclude file in your
git
# repo. These rules are not committed with the repo so they are not sharedide
# 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.開發工具
.settingsgradle
.classpathui
binidea
coveragespa
coverage.eccode
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
此時打開開發工具便可實現想要的過濾效果了。