3

I'm new to Git and Android development and I could not find an answer to this question.

When I build a project in Android Studio a lot of files are created in the folder app/build.

I guess I don't need that files, but before ignoring them in the .gitignore, I would like to be sure to not mess my repo since from the first commit :D

I checked this question, but I cannot see in the example .gitignore the folder app/build.

Should I add it to my .gitignore?

P.S. I'm using Android Studio 2.2.3, if relevant

Community
  • 1
  • 1

3 Answers3

3

I guess I don't need that files, but before ignoring them in the .gitignore I would like to be sure to not mess my repo since from the first commit :D

You don't need build files in your repo.

Usually .gitignore file contains /build.

I checked this question but I cannot see in the example .gitignore the folder app/build.

You can place another one .gitignore file to app directory, the content of this file also contains /build.

/project
     .gitignore
     /app
         .gitignore
Vasily Kabunov
  • 6,511
  • 13
  • 49
  • 53
2

If I copy/past the example .gitignore (which contains build/ ) in the app/ folder, build files are not ignored.

That would be because those files are already tracked.

Try:

cd app
git rm --cached -r build/
git add .
git commit -m "record build content deletion"
git push

Then app/build will be ignored.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Have a look at gitignore.io for generating gitignore files

Isaac
  • 1,442
  • 17
  • 26