什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
什么文件应该在我的。gitignore为一个Android工作室项目?
我见过几个包含。iml的例子,但是IntelliJ文档说。iml必须包含在你的源代码控制中。
当前回答
我的建议是不要忽略。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),但我很高兴它起作用了。
其他回答
取决于你的项目格式是如何维护的:
你有两个选择:
基于目录的格式(您将有一个.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 0.8.4开始,启动新项目时自动生成gitignore文件。默认情况下,它包含:
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
build/
/captures
我同意这个说法,但是我修改了这个文件来改变 /建造到建造/ (包括/build和/app/build) 这样我就不会把所有的文件都放在app/build中。
还要注意,如果从Eclipse导入项目,.gitignore不会被复制,也不会“自动地”为您创建。
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 Chipmunk 2021.2.1
如果你使用Android Studio创建Gradle项目,.gitignore文件将包含以下内容:
. gitignore
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
我建议忽略完整的”。目录,因为它包含特定于用户的配置,对于构建过程没有什么重要的。
Gradle项目文件夹
在存储库克隆之后,你的(Gradle)项目文件夹中唯一应该存在的东西是这样的结构(至少对于我目前遇到的用例来说是这样的):
app/
.git/
gradle/
build.gradle
.gitignore
gradle.properties
gradlew
gradlew.bat
settings.gradle
注意:建议像这里描述的那样签入gradle包装器脚本(gradlew, gradlew.bat)。
要使Wrapper文件对其他开发人员和执行环境可用,您需要将它们检入版本控制。
我用这个。gitignore。我在http://th4t.net/android-studio-gitignore.html找到了它
*.iml
*.iws
*.ipr
.idea/
.gradle/
local.properties
*/build/
*~
*.swp