0

If I checkout a branch, make no changes but gradle does a full rebuild of the project, when i go to checkout a different branch, it git gives me a error in the terminal saying changes have been made to the

modified:   .idea/workspace.xml
modified:   app/app.iml

even though i didnt make any changes, they were done android studio, and it says everytime that I have to commit in order to checkout another branch. are these changes important ? can I just remove/revert or dont save the changes? or do I have to commit every time? Can I just add these two files to my gitignore? As I dont actually know what changes it making so dont know what to put in the commit message. are they just changes in the project settings? can I disregard them ?

Andrew Irwin
  • 691
  • 12
  • 40
  • 1
    If you read [these gitignores](http://stackoverflow.com/q/16736856/2668136), these files are ignored by many devs and IDE themselves. These two files are the settings of the IDE. Maybe a little thing changes between branches but this should be not important. Try to ignore it in .gitignore file. – Blo May 17 '16 at 16:20

4 Answers4

1

You can ignore app.iml, it always modified by gradle build system

Jitendra Prajapati
  • 1,002
  • 1
  • 10
  • 33
1

You can disregard these changes. They are Android Studio project files. The easiest way to ignore the changes is by adding or modifying a gitignore file. This file will tell git to ignore certain files, or files with names matching a pattern.

davehenry
  • 1,026
  • 9
  • 24
  • thanks guys, i think im going to use the git ignore that Fllo suggested in his comment above. *.iml .gradle /local.properties /.idea/workspace.xml /.idea/libraries .DS_Store /build /captures – Andrew Irwin May 17 '16 at 16:35
1

remove the modifications with 'git checkout -f -- FILE1 FILE2' and then change branches. If git is complaining about them then they are already being tracked, and .gitignore won't help. You may be able to stop tracking them with 'git rm '

you can remove all the modifications with 'git checkout -f' but be sure there are no source code changes also.

Gregg
  • 2,444
  • 1
  • 12
  • 21
1

All of the answers I've seen are correct, but here is an explanation:

Android Studio needs to create many files during the build process - including the build itself (apk file). These files are generally temporary and unnecessary for version control, but they are necessary for the build and maybe helpful for troubleshooting problems.

The best way to handle this is to use the .gitignore file to tell your repo to ignore these files. The repo does not need to track them because you do not care about changes to these files. Android Studio created them and it can create them again from your the files you do track.

Your git repo is there to help you track changes to files that you either cannot recreate or need to recreate for code maintenance purposes. None of these files fall into those categories. (In some rare cases you may want to track some of these files - but until you find a need, ignore them.)

Jim
  • 10,172
  • 1
  • 27
  • 36