Reputation: 711
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 ?
Upvotes: 0
Views: 1872
Reputation: 10288
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.)
Upvotes: 1
Reputation: 2624
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.
Upvotes: 1
Reputation: 1076
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.
Upvotes: 1
Reputation: 1161
You can ignore app.iml, it always modified by gradle build system
Upvotes: 1