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.
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.
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.
精彩评论