git已经添加到仓库中的文件无法直接使用.gitignore来进行忽略,需要先清理git缓存,再重新add,此时git才会按照.gitignore的规则对文件进行筛选,操作如下:
git -r --cached .
git add .
然后继续commit和push操作即可
附常用.gitignore忽略文件写法:
# Built application files //
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
.idea
# Keystore files
*.jks