什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
当前回答
我支持提交。idea文件夹(不包括workspace.xml和tasks.xml)。但我开始得出结论,.iml文件应该被忽略。
问题在于:
例如,在名为“foo”的目录下打开一个项目,你将得到foo。我和那一切看起来都很好。问题是,如果我只是将目录重命名为foo2(或克隆为另一个目录名),当你尝试在Android Studio中打开项目时,你会得到三件事:
一个名为foo2.iml的新iml文件 你的Android项目的iml文件将被更改为指向foo2作为它的父文件 .idea/modules.xml将为foo2添加一行。它既有旧的Iml文件,也有新目录的Iml文件
我找不到方法来阻止Android工作室做这个iml文件生成时,项目存储在一个不同的目录。将它们添加到源代码控制中会导致问题。因此,我认为也许我们应该忽略*。Iml文件和。idea/modules.xml
其他回答
取决于你的项目格式是如何维护的:
你有两个选择:
基于目录的格式(您将有一个.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
为了避免所有文件的导入,Android Studio忽略“Ignored files”列表,但仍然利用Android Studio VCS,我做了以下工作: 这将使用Android Studio中的“忽略文件”列表(导入后!并且避免使用龟SVN设置SVN:ignore列表的繁琐方式。
使用Tortoise SVN存储库浏览器直接在存储库中创建一个新的项目文件夹。 使用Tortoise SVN在要导入的文件夹上方签出新文件夹。您将得到一个警告,说明本地文件夹不是空的。忽略警告。现在,您有了一个版本化的顶级文件夹,其中包含未版本化的内容。 从本地工作目录打开项目。VCS现在应该自动启用了 在“文件->设置->版本控制->忽略文件”中设置文件例外 从Android Studio添加文件到SVN:在项目结构中选择“App”-> VCS ->添加到VCS(这将添加所有文件,除了“忽略文件”) 提交修改
下一步,“被忽略的文件”将被忽略,你仍然可以从Android Studio管理VCS。
干杯, -Joost
在Android Studio中,唯一需要保存在版本控制中的文件是使用gradle从命令行构建应用程序所需的文件。所以你可以忽略:
* .iml .idea 构建
但是,如果您保存任何IDE设置,例如自定义代码样式设置,它们将保存在.idea文件夹中。如果您希望在版本控制中进行这些更改,那么您也可以保存IDEA文件(*。Iml和idea)。
使用gitignore提供的api。Io,你可以得到的是自动生成的。这里是gitignore.io/api/androidstudio的直接链接
### AndroidStudio ###
# Covers files to be ignored for android development using Android Studio.
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle
.gradle/
build/
# Signing files
.signing/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio
/*/build/
/*/local.properties
/*/out
/*/*/build
/*/*/production
captures/
.navigation/
*.ipr
*~
*.swp
# Android Patch
gen-external-apklibs
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# NDK
obj/
# IntelliJ IDEA
*.iml
*.iws
/out/
# User-specific configurations
.idea/caches/
.idea/libraries/
.idea/shelf/
.idea/workspace.xml
.idea/tasks.xml
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
.idea/datasources.xml
.idea/dataSources.ids
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
.idea/assetWizardSettings.xml
# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Legacy Eclipse project files
.classpath
.project
.cproject
.settings/
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.war
*.ear
# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
hs_err_pid*
## Plugin-specific files:
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Mongo Explorer plugin
.idea/mongoSettings.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### AndroidStudio Patch ###
!/gradle/wrapper/gradle-wrapper.jar
# End of https://www.gitignore.io/api/androidstudio
在我正常的Android .gitignore的基础上,在阅读Intellij IDEA网站上的文档和阅读StackOverflow上的帖子后,我构建了以下文件:
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# built native files (uncomment if you build your own)
# *.o
# *.so
# generated files
bin/
gen/
# Ignore gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Eclipse Metadata
.metadata/
# Mac OS X clutter
*.DS_Store
# Windows clutter
Thumbs.db
# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids
还要注意,正如所指出的,当你用Android NDK构建自己的本机代码时,构建的本机文件部分主要是有用的。另一方面,如果您正在使用包含这些文件的第三方库,则可能希望删除这些行(*。O和*.so)来自你的。gitignore。