yiwai 发表于 2018-1-13 18:33:42

Android Studio上使用Git配置全局gitignore

  每次用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
  

# Built application files  
*.apk
  
*.ap_
  

  
# Files for the ART/Dalvik VM
  
*.dex
  


  
# Java>  
*.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/workspace.xml
  
.idea/tasks.xml
  
.idea/gradle.xml
  
.idea/dictionaries
  
.idea/libraries
  

  
# Keystore files
  
*.jks
  

  
# 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
  

  3、保存为.gitignore_global的一个文件,在windows上提示必须输入文件名,可以在记事本上点另存为,这样就不会要求输入文件名了
  4、打开Git Bash 输入$ git config --global core.excludesfile ~/.gitignore_global
  5、打开.gitconfig,可以看到多了excludesfile = c:/Users/你的账户文件夹/.gitignore_global,所以也可以不通过Git Bash,而是手动在.gitconfig添加这段内容,完成全局忽略设置
  6、以后有其他需要全局忽略的文件,直接添加到.gitignore_global里面就可以了
页: [1]
查看完整版本: Android Studio上使用Git配置全局gitignore