3

I saw the post "How do I tell git to always select my local version for conflicted merges on a specific file?", which says if you have conflict on a folder, we need to add .gitattributes to that folder and then add a merge driver to config file to say always keep my branch's content for this folder.
And this works perfectly fine.

But what if I end with up conflicts on several folders/files and want to keep my version for these. It doesn't make sense to create .gitattributes file in every folder that has conflicts.

So is there a way to do this - like if am merging Branch-A to Branch-B and end up with so many conflicts, I need a way by which I can keep Branch-B contents for all the conflicts.
Any help is appreciated.

Community
  • 1
  • 1
Hariharan
  • 31
  • 2

1 Answers1

2

If you want to take branch B's version for all conflicts, you can simply use a merge strategy option:

git merge -X ours branchB

This will merge normally (using the default recursive strategy) until it runs into a conflicting hunk, at which point it'll automatically take branch B's version of the hunk.

Cascabel
  • 479,068
  • 72
  • 370
  • 318
  • I got another suggestion from a guy, asking me to do git checkout --ours/theirs filename to merge the files.... do you see any potential difference between the two? – Hariharan Jul 14 '10 at 00:19