Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

git - Android Studio项目的.gitignore应该是什么?(What should be in my .gitignore for an Android Studio project?)

What files should be in my .gitignore for an Android Studio project?

(Android Studio项目的.gitignore文件中应该包含哪些文件?)

I've seen several examples that all include .iml but IntelliJ docs say that .iml must be included in your source control.

(我已经看到了几个都包含.iml示例,但是IntelliJ文档说.iml必须包含在源代码控件中。)

  ask by respectTheCode translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Updated to Android Studio 3.0 Please share missing items in comments.

(更新至Android Studio 3.0。请分享评论中缺少的内容。)

A late answer but none of the answers here and here was right on the money for us...

(答案很晚,但这里和这里的答案都不对,这对我们来说是钱...)

So, here's our gitignore file:

(因此,这是我们的gitignore文件:)

#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

# 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

Since Android Studio 2.2 and up to 3.0, new projects are created with this gitignore file:

(从Android Studio 2.2及更高版本开始,使用gitignore文件创建新项目:)

*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild

Deprecated - for older project format, add this section to your gitignore file:

(不推荐使用 -对于较旧的项目格式,请将此部分添加到您的gitignore文件中:)


/*/out
/*/*/build
/*/*/production
*.iws
*.ipr
*~
*.swp

This file should be located in the project's root folder and not inside the project's module folder.

(该文件应位于项目的根文件夹中,而不应位于项目的模块文件夹中。)

Edit Notes:

(编辑注释:)

  1. Since version 0.3+ it seems you can commit and push *.iml and build.gradle files.

    (从0.3+版本开始,您似乎可以提交并推送* .imlbuild.gradle文件。)

    If your project is based on Gradle: in the new open/import dialog, you should check the "use auto import" checkbox and mark the "use default gradle wrapper (recommended)" radio button.

    (如果您的项目基于Gradle:在新的打开/导入对话框中,则应选中"use auto import"复选框,并标记"use default gradle wrapper (recommended)"单选按钮。)

    All paths are now relative as @George suggested.

    (现在所有路径都是相对的,如@George所建议。)

  2. Updated answer according to @128KB attached source and @Skela suggestions

    (根据@ 128KB 附件来源和@Skela建议更新了答案)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...