tags:

views:

114

answers:

2

I'm trying to do a merge and there's a bunch of conflicts. It's all generated files so what I want to do is basically say "ignore all merge conflicts, and check everything in from my own repo".

I've tried

git checkout . --ours
git add -A
git com -a

It gives me an error though because there are still files in the "unmerged paths" bucket. How do I handle this?

Thanks!

A: 

Git commands are very wary of hiding conflicts - you pretty much have to explicitly check in a conflicted file to let it know that it's fixed. It does seem odd that there's not a -f style option for git add to let it know you really mean it, but here's an alias that I have which will help:

add-unmerged = \
    "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"

Bonus tip: if you change "git add" to $EDITOR, you now have edit-unmerged, for editing all the conflicted files!

Jefromi
+1  A: 

Use a custom merge driver:
you can declare that driver in a .gitattributes located in the right directory (the one with the generated files whose merge you do not want to deal with)

* merge=keepMine

(you can specify a more precise pattern to isolate the exact files concerned with that custom merge)

with the config:

[merge "keepMine"]
        name = always keep mine during merge
        driver = keepMine.sh %O %A %B

See "How do I tell git to always select my local version for conflicted merges on a specific file?" for a complete example.

VonC
Ah, good call. I was assuming that the OP still wanted to (or had to) manually grab the correct versions of the files, but since they're generated files it should be possible to target them all with a merge driver!
Jefromi