什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
当前回答
这份来自JetBrains Support的官方文档认为应该包含以下内容:
All files under .idea directory except workspace.xml and tasks.xml because
they store specific user settings
All the *.iml files that can be located in different module directories
它还给出了其他需要注意的事项的建议。
其他回答
https://github.com/github/gitignore是很棒的收藏
Android.gitignore
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.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/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.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
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
更新到Android Studio 3.0 请在评论中分享遗漏的项目。
一个迟来的答案,但这个替代答案不适合我们……
这是我们的gitignore文件:
#built application files
*.apk
*.ap_
*.aab
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Android Studio
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
.navigation
captures/
output.json
#NDK
obj/
.externalNativeBuild
从Android Studio 2.2到3.0,新项目都是用这个gitignore文件创建的:
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
已弃用-对于旧的项目格式,将此部分添加到您的gitignore文件:
/*/out
/*/*/build
/*/*/production
*.iws
*.ipr
*~
*.swp
该文件应该位于项目的根文件夹中,而不是在项目的模块文件夹中。
编辑笔记:
从0.3+版本开始,似乎你可以提交和推送*。我和建造。gradle文件。如果你的项目基于Gradle:在新的打开/导入对话框中,你应该选中“使用自动导入”复选框,并标记“使用默认Gradle包装器(推荐)”单选按钮。所有路径现在都是相对的@George建议。 根据@128KB附件来源和@Skela建议更新了答案
更新:7/2015
以下是来自JetBrains的确切来源
基于目录的项目格式(。想法目录)
默认情况下,所有最新的IDE版本都使用这种格式。以下是你需要分享的内容:
项目根目录下的。idea目录下的所有文件,除了存放用户特定设置的workspace.xml和tasks.xml文件 可以位于不同模块目录下的所有.iml模块文件(适用于IntelliJ IDEA)
分享以下信息时要小心:
生成签名构建的Android构件(将包含密钥库密码) 在IDEA 13和更早的数据源中。id、datasources.xml可以包含数据库密码。IDEA 14解决了这个问题。
你可考虑不分享以下资料:
xml文件,请参阅此讨论 用户字典文件夹(如果其他开发人员有相同的名称,可以避免冲突) .idea/libraries下的XML文件,以防它们是从Gradle项目中生成的
遗留项目格式(.ipr/.iml/。技术手册文件)
共享项目的。ipr文件和所有的。iml模块文件,不要共享。iws文件,因为它存储了用户特定的设置
虽然这些说明是针对IntelliJ IDEA的,但它们100%适用于Android Studio。
下面是一个.gitignore代码片段,它包含了上述所有规则:
# Android Studio / IntelliJ IDEA
*.iws
.idea/libraries
.idea/tasks.xml
.idea/vcs.xml
.idea/workspace.xml
最好在整个开发过程中添加.gitignore列表,以防止版本控制由于某处预定义的(复制/粘贴)列表而无法工作时产生未知的副作用。对于我的一个项目,忽略列表只有:
.gradle
.idea
libs
obj
build
*.log
我的建议是不要忽略。idea文件夹。
我已经将一个基于git的Eclipse项目导入到Android Studio,效果很好。后来,我想用Git导入这个项目(就像第一次一样)到另一台带有Android Studio的机器上,但没有成功。Android Studio确实加载了所有文件,但无法将项目“视为”项目。我只能打开Git-files。
当第一次导入项目(从Eclipse到Android Studio)时,我的旧的.gitignore被覆盖了,新的看起来像这样:
.idea / . name .idea / compiler.xml .idea /版权/ profiles_settings.xml .idea / encodings.xml .idea /图书馆/ libs.xml .idea / misc.xml .idea / modules.xml .idea /范围/ scope_settings.xml .idea / vcs.xml .idea / workspace.xml
所以,我试着用一个空的gitignore,现在它工作了。另一个Android Studio可以加载文件和项目。我猜有些文件对于Git和导入来说并不重要(profiles_settings.xml),但我很高兴它起作用了。