Android Studio的.gitignore以及gitignore无效的解决

  github上.gitignore模板合集,里面有各种.gitignore : https://github.com/github/gitignore

  自己用的Android Studio下项目的.gitignore文件,对github上的android.gitignore添加了

      # OSX files      //mac os下
      .DS_Store

      # Android Studio
      *.iml
      .idea

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# OSX files
.DS_Store

# Android Studio
*.iml
.idea

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

  有时我们发现添加.gitignore文件后并没有忽略我们想要忽略的文件,解决方法就是清除一下缓存,原因gitignore对已经追踪(track)的文件无效,清除缓存后文件将以未追踪的形式出现.然后再重新添加提交一下,.gitignore文件里的规则就可以起作用了

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

  清缓存生效方法参考:http://niltor.net/index.php/Home/Blog/showblog?id=5

 

猜你喜欢

转载自rewufu.iteye.com/blog/2223365