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!
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With