每次用Android Studio新建一個工程,都要重新配置gitignore文件,查了一下知道了怎么配置全局忽略文件。
參考原文:http://www.cnblogs.com/Cherry-B/p/4583505.html?utm_source=tuicool&utm_medium=referral
1、用戶賬戶文件夾(路徑:C:\Users\xxxx , xxx為你的賬戶),該目錄下有一個.gitconfig的文件,里面保存了git的一些全局參數,如用戶名和郵箱等
2、在該目錄下打開記事本輸入以下內容,這是安卓開發Git的可忽略文件,來自https://github.com/github/gitignore
1 # Built application files 2 *.apk 3 *.ap_ 4 5 # Files for the ART/Dalvik VM 6 *.dex 7 8 # Java class files 9 *.class 10 11 # Generated files 12 bin/ 13 gen/ 14 out/ 15 16 # Gradle files 17 .gradle/ 18 build/ 19 20 # Local configuration file (sdk path, etc) 21 local.properties 22 23 # Proguard folder generated by Eclipse 24 proguard/ 25 26 # Log Files 27 *.log 28 29 # Android Studio Navigation editor temp files 30 .navigation/ 31 32 # Android Studio captures folder 33 captures/ 34 35 # Intellij 36 *.iml 37 .idea/workspace.xml 38 .idea/tasks.xml 39 .idea/gradle.xml 40 .idea/dictionaries 41 .idea/libraries 42 43 # Keystore files 44 *.jks 45 46 # External native build folder generated in Android Studio 2.2 and later 47 .externalNativeBuild 48 49 # Google Services (e.g. APIs or Firebase) 50 google-services.json 51 52 # Freeline 53 freeline.py 54 freeline/ 55 freeline_project_description.json
3、保存為.gitignore_global的一個文件,在windows上提示必須輸入文件名,可以在記事本上點另存為,這樣就不會要求輸入文件名了
4、打開Git Bash 輸入$ git config --global core.excludesfile ~/.gitignore_global
5、打開.gitconfig,可以看到多了[core]excludesfile = c:/Users/你的賬戶文件夾/.gitignore_global ,所以也可以不通過Git Bash,而是手動在.gitconfig添加這段內容,完成全局忽略設置
6、以后有其他需要全局忽略的文件,直接添加到.gitignore_global里面就可以了