问题
I am having a problem building a .gitignore file for my Android Studio workspace, this is my folder setup:
Android Workspace---
-> School/Application1, Application2, etc.,
-> Projects/Application1, Application2, etc.
Android Workspace is the master folder, School and Projects are used to organize my applications, They contain the folders created when I create a new Android Studio project.
I created a .gitignore file and placed it in Android Workspace, but it doesn't seem to be ignoring the files, I then tried placing two .gitignore files in each sub directory, but that didn't work either, so, my question is: How do I structure my .gitignore file to ignore the unnecessary Android Studio files from the Android Workspace folder no matter how deeply nested they are? Or do I have to place a .gitignore in each of the application's directory?
Thanks, and here's the .gitignore file I'm using (Generated by https://www.gitignore.io/):
### Android ###
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
/*/build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
回答1:
You can create a global .gitignore that will have the files/folders to be ignored in all git projects. For this, just run the following command
git config --global core.excludesfile ~/.gitignore_global
It will create a .gitignore_global
file in your home folder that should have the files/folders to be ignored.
来源:https://stackoverflow.com/questions/28923160/gitignore-file-for-multiple-android-projects-under-a-master-folder