6

I need to add this file on git (Android Studio Project)
app/build/outputs/mapping/my_flavor/relese/mapping.txt
This is my .gitignore file (root of the project)

...
build/
*/build/
!build/outputs/mapping/my_flavor/release
...

This is my .gitignore file (module app)

...
/build
!/build/outputs/mapping/my_flavor/release
...

The files contained in app/build/outputs/mapping/my_flavor/release are always excluded by git.
Any suggetion on how I can solve it?
Regards

Rino
  • 733
  • 8
  • 19
  • The mapping file is a build artifact, putting it under version control is a bad idea. Instead, store it along with the apk it corresponds to. – 1615903 Jul 05 '16 at 08:03
  • Hi, thank you for your answer. After build the release apk, I will tag it...so the proguard file will match the exact version of the app. However, your comment did not answer to my question. – Rino Jul 05 '16 at 08:09

2 Answers2

6

Easiest way:

git add -f app/build/outputs/mapping/my_flavor/release/mapping.txt

You only need to use the -f flag the first time - .gitignore does not work for files that are already tracked.

However, I would recommend treating the mapping.txt file as a build artifact and NOT add it to version control, instead, store it along with your .apk file to wherever you are storing build artifacts.

1615903
  • 32,635
  • 12
  • 70
  • 99
1

It is possible to handle it in .gitignore file.

If you want to ignore the whole content of a directory except one file inside it, you could write a pair of rules for each directory in the file path.

!/build
/build/*
!/build/outputs
/build/outputs/*
!/build/outputs
/build/outputs/mapping/*
!/build/outputs/mapping
/build/outputs/mapping/my_flavor/*
!/build/outputs/mapping/my_flavor
/build/outputs/mapping/my_flavor/release/*
!/build/outputs/mapping/my_flavor/release
!/build/outputs/mapping/my_flavor/release/mapping.txt

PS: You have typo app/build/outputs/mapping/my_flavor/relese/mapping.txt

Read more

Community
  • 1
  • 1
koliczyna
  • 280
  • 1
  • 11