Where to put gitIgnore file in Android Studio?

蹲街弑〆低调 提交于 2019-12-04 19:17:51

问题


I am developing an app and I must take that project to GitHub. Now, I must make gitIgnore file. I know that file is used to ignore some specified files from my project. I used gitIgnore.io service and I received generated file. This is my gitIgnore file:

# Created by https://www.gitignore.io/api/android

### Android ###
# 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

# Keystore files
*.jks

### Android Patch ###
gen-external-apklibs

But I don't know were to copy this, and where to put that in my Android project. Could someone help me?

I copied this file into my gitIgnore file in Android Studio, but when I have pushed that project on gitHub my gitnigore file looks like this:

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

So, that files that I copied into Android Studio are not here. What is the problem?


回答1:


Normally when creating a new project the gitignore file is generated for you.

Here is the correct .gitignore file.

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

This is were you have to put it.




回答2:


.gitignore file must be in the root directory of the project not just in android projects but in any project types

I hope my answer would be useful




回答3:


Check out this handy page on Github - the ignore files for other types of projects are there as well and regularly updated.



来源:https://stackoverflow.com/questions/38219957/where-to-put-gitignore-file-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!