0

I was working on my Android app in a development branch. I am at a point where I want to merge my changes into master, I figured I'd use the method suggested in the answer here where I merge master into the dev branch to take care of any potential issues before actually going to master. So I executed the following commands while in my dev branch:

git add . - to add all my current changes

git commit -m"My commit message - to commit my changes

git push origin devBranch - to push my changes up to github

git merge master - to merge my master branch into the dev branch

This is when I was hit with the following conflicts which I had never seen before:

warning: Cannot merge binary files: app/build/intermediates/res/resources-debug.ap_ (HEAD vs. master)
Auto-merging app/build/intermediates/res/resources-debug.ap_
CONFLICT (content): Merge conflict in app/build/intermediates/res/resources-debug.ap_
Auto-merging app/build/intermediates/incremental/mergeDebugResources/merger.xml
CONFLICT (content): Merge conflict in app/build/intermediates/incremental/mergeDebugResources/merger.xml
Auto-merging app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
CONFLICT (add/add): Merge conflict in app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Auto-merging app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v17/values-v17.xml
CONFLICT (add/add): Merge conflict in app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v17/values-v17.xml
Auto-merging app/build/intermediates/incremental/mergeDebugResources/compile-file-map.properties
CONFLICT (content): Merge conflict in app/build/intermediates/incremental/mergeDebugResources/compile-file-map.properties
Auto-merging app/build/intermediates/incremental/mergeDebugAndroidTestResources/compile-file-map.properties
CONFLICT (content): Merge conflict in app/build/intermediates/incremental/mergeDebugAndroidTestResources/compile-file-map.properties
Auto-merging app/build/intermediates/blame/res/debug/single/layout.json
CONFLICT (content): Merge conflict in app/build/intermediates/blame/res/debug/single/layout.json
Auto-merging app/build/intermediates/blame/res/debug/single/drawable.json
CONFLICT (content): Merge conflict in app/build/intermediates/blame/res/debug/single/drawable.json
Auto-merging app/build/intermediates/blame/res/debug/single/drawable-xhdpi-v4.json
CONFLICT (content): Merge conflict in app/build/intermediates/blame/res/debug/single/drawable-xhdpi-v4.json
Auto-merging app/build/intermediates/blame/res/debug/single/drawable-hdpi-v4.json
CONFLICT (content): Merge conflict in app/build/intermediates/blame/res/debug/single/drawable-hdpi-v4.json
Auto-merging app/build/intermediates/blame/res/debug/multi/values.json
CONFLICT (content): Merge conflict in app/build/intermediates/blame/res/debug/multi/values.json
Automatic merge failed; fix conflicts and then commit the result.

My issue is that I don't know how to fix these conflicts since they're in intermediate files that I've never touched, I'm assuming this is all generated code. Maybe I'm getting myself into trouble by doing git add . but that's the way I've always done it, adding each individual file I change doesn't seem practical (and I would want to add the changed generated file too, wouldn't I?).

Am I getting these conflicts due to the way I'm merging? If I switch over to my master branch and merge the dev branch into master would I have the same issues? I'm afraid to try this, but it was the way I was merging changes previously and never gave me any issues like this.

intA
  • 2,513
  • 12
  • 41
  • 66
  • 1
    This has a bad smell. Your intermediate build target directory should ideally not even be visible to Git. The fix is to not have build files inside the `.git` folder. – Tim Biegeleisen Jun 20 '17 at 02:49
  • 1
    Add a `.gitignore` file with a `app/build/` line in it. You can find a great example here: https://github.com/github/gitignore/blob/master/Android.gitignore. After adding it you can just `git rm` the build folder. Build products should almost never be in source control. – jjm Jun 20 '17 at 02:50

1 Answers1

2

Make your .gitignore file like this:

.idea
out
target
*.iml
log
local.properties
build
android/libs
/.gradle

Commit it and then do merge.

Oleg Sokolov
  • 1,134
  • 1
  • 12
  • 19