¿Es posible hacer que git automatice la resolución de ciertos tipos de conflictos de fusión?

We have two branches X and Y that have been branched at this point:


Now branch X introduces some changes into dir/a.txt and a commit is created. Branch Y makes a commit where dir/ gets deleted.

Then we want to merge X into Y. This will create a certain kind of "deleted-changed" conflict. Is it possible to instruct git to always "use ours" when it detects this specific conflict for the specific branch (Y) and a specific set of files (dir/*) ?

preguntado el 31 de julio de 12 a las 15:07

I do know that git has pluggable merge strategy modules. git-merge-recursive is the default. It might be possible for you to create a new one there and make it decide based on the scenario but that's a lot of work. -

1 Respuestas

Read the section on merge strategies in the página de manual. Puede especificar -s ours or -s theirs to choose to use the version from one branch or another entirely. Or you can have it prefer to resolve conflicts using one or the other using the recursive merge with either ours or theirs recursive strategies. Note these are not the same things.

In the above case, if you are on Y and you merge X with git merge -s ours X it will produce a result with changes from branch Y.

Respondido 31 Jul 12, 15:07

Thanks, that's not 100% what I needed, but the information led me to the discovery of file-specific rules in .gitattributes: git-scm.com/book/ch7-2.html#merge_strategies - Eugene

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.