什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
当前回答
为了更好地理解,您只需要以下文件
应用程序 build.gradle settings.gradle
您可以将其他所有内容放在.gitignore文件中。你所有的应用变化都在这些文件和文件夹中。你在基本项目中看到的其他文件是gradle构建文件或Android Studio配置文件。
如果你正在使用Android Studio,你可以使用“Import project”来成功构建项目。或者你也可以使用命令行构建,使用Gradle构建Android项目。
其他回答
取决于你的项目格式是如何维护的:
你有两个选择:
基于目录的格式(您将有一个.idea文件夹,其中包含 项目特定文件) 基于文件的格式(配置文件为。iws和。ipr)
裁判: http://www.jetbrains.com/idea/webhelp/project.html
提交给版本控制的文件依赖于上述:
包括。idea文件夹到版本控制,排除workspace.xml和 tasks.xml 版本控制的.ipr文件和所有的.iml模块文件,排除 iws文件,因为它存储了用户特定的设置。
裁判: https://intellij-support.jetbrains.com/entries/23393067
我是kosher添加。iml文件和Intellij sez添加。idea文件夹,但忽略。idea/workspace.xml和。idea/tasks.xml,但。idea/libraries/呢?
我不明白加这个有什么意义。它有一个XML文件列表,列出了Android Studio项目应该知道的库。这些应该来自于构建。gradle定义的依赖项——不是IDE项目文件。
其中一个文件的内容是这样的:
<component name="libraryTable">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/artifacts-26/filestore/com.example/example/etc...jar!"/>
这样做没有意义。如果用户为gradle指定了不同的主目录,或者如果他们使用了不同的gradle版本,.gradle/caches/artifacts-xxx下的路径对他们来说将是不同的(即工件-在末尾追加的数字将与您正在使用的gradle版本发布相关)。这些路径不是通用的,但建议是检查所有这些?
我合并Github .gitignore文件
Android.gitignore JetBrains.gitignore
### Github Android.gitignore ###
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# 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/
### Github JetBrains.gitignore ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
请阅读:JetBrains支持:如何在版本控制系统下管理项目
这是通过这里生成。gitignore的最好方法
基本上是自动重新生成的任何文件。
一个很好的测试是克隆你的repo,看看Android Studio是否能够立即解释和运行你的项目(生成缺少的东西)。 如果没有,找到丢失的内容,并确保它没有被忽略,而是添加到回购中。
也就是说,你可以在现有的.gitignore文件上举例,比如Android文件。
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Eclipse project files
.classpath
.project
# Proguard folder generated by Eclipse
proguard/
# Intellij project files
*.iml
*.ipr
*.iws
.idea/