Git - how to always accept the contents of my branch when in conflict?

I saw the message How do I tell git to always select the local version for conflicting merges for a specific file? , which says that if you have a conflict in a folder, we need to add .gitattributesto this folder and then add the merge driver to the configuration file so that it always saves the contents of the branch for this folder.
And it works great.

But what if I ended the conflicts on several folders / files and want to keep my version for them. It makes no sense to create a file .gitattributesin each folder with conflicts.

So, is there a way to do this - for example, if I combine Branch-Ain Branch-Band end with so many conflicts, I need a way that I can store content Branch-Bfor all conflicts. Any help is appreciated.

+3
source share
1 answer

If you want to use branch B for all conflicts, you can simply use the merge strategy:

git merge -X ours branchB

This will merge normally (using the default recursive strategy) until it encounters a conflicting machine, at which point it will automatically get the version of the branch of version B.

+2
source

Source: https://habr.com/ru/post/1754328/


All Articles