0

I see that, when creating a new project in Android Studio (v2.2.2), a .gitignore file is automatically created. It consists of the following:

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

The project folder consists of the following files/directories at the root:

Tele1.iml
app
build
build.gradle
gradle
gradle.properties
gradlew
gradlew.bat
local.properties
settings.gradle

Based on this, what is the proper way to commit the basic, default project to Git? Can I simply do git add . and can expect that what should be committed will be and what should be won't? If I do this, this is what gets added to the repository:

A  .gitignore
A  .idea/compiler.xml
A  .idea/copyright/profiles_settings.xml
A  .idea/gradle.xml
A  .idea/misc.xml
A  .idea/modules.xml
A  .idea/runConfigurations.xml
A  .idea/vcs.xml
A  app/.gitignore
A  app/build.gradle
A  app/proguard-rules.pro
A  app/src/androidTest/java/local/abc/tele1/ExampleInstrumentedTest.java
A  app/src/main/AndroidManifest.xml
A  app/src/main/java/local/abc/tele1/MainActivity.java
A  app/src/main/res/layout/activity_main.xml
A  app/src/main/res/mipmap-hdpi/ic_launcher.png
A  app/src/main/res/mipmap-mdpi/ic_launcher.png
A  app/src/main/res/mipmap-xhdpi/ic_launcher.png
A  app/src/main/res/mipmap-xxhdpi/ic_launcher.png
A  app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
A  app/src/main/res/values-w820dp/dimens.xml
A  app/src/main/res/values/colors.xml
A  app/src/main/res/values/dimens.xml
A  app/src/main/res/values/strings.xml
A  app/src/main/res/values/styles.xml
A  app/src/test/java/local/abc/tele1/ExampleUnitTest.java
A  build.gradle
A  gradle.properties
A  gradle/wrapper/gradle-wrapper.jar
A  gradle/wrapper/gradle-wrapper.properties
A  gradlew
A  gradlew.bat
A  settings.gradle

Many blogs have talked about this and many say different things and I'm not sure what is right and wrong. Thanks.

rityzmon
  • 1,945
  • 16
  • 26

2 Answers2

0

Yes, making:

   git add .
   git commit
   git push

is fine because all the files generated in build/, for example, are excluded. iml files can also be excluded as reported here. When using Android Studio, the ISE just use these commands to commit/push.

Community
  • 1
  • 1
JFL
  • 1,502
  • 14
  • 18
0

Before you make the first commit you can edit the .gitignore and use this resource https://github.com/github/gitignore

Just choose the android.gitignore and add it to your project.