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

 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里面就可以了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM