git之push到远端仓库后修改.gitignore忽略规则后新规则不起作用解决办法

  • 添加.gitignore文件后并没有忽略我们想要忽略的文件,解决方法就是清除一下缓存,原因gitignore对已经追踪(track)的文件无效,清除缓存后文件将以未追踪的形式出现(清楚后编译器关闭重新打开一下,重新加载刷新一下文件),然后再重新添加提交一下,.gitignore文件里的规则就可以起作用了。
  1. git rm -r --cached .
  2. 关闭编译器重新打开
  3. git add .
  4. git commit -m 'update .gitignore'
  5. git push -u origin master (如果有远程仓库则使用)
  • .gitignore配置模板
# Built application files
*.apk
*.ap_
*.aab

# 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/
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
.idea/modules.xml
.idea/navEditor.xml
.idea/Project.xml
.DS_Store
.cxx

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

你可能感兴趣的:(git之push到远端仓库后修改.gitignore忽略规则后新规则不起作用解决办法)