I came across sitaution, where developers on their own branches will modify one file - it's some kind of global file which is generated automatically.
The thing is, that this automatic generation occurs every times at the end of a file. So, file on remote repo looks like:
this is first line.
Then, two developers on two different branches might have:
this is first line.
this was added by developer A.
and
this is first line.
this was added by developer B.
That's all. Clearly, there will be conflict when merging.
But resolution is simple: always take one side, then the other side (order does not matter), so the valid result might be:
this is first line.
this was added by developer B.
this was added by developer A.
as well as
this is first line.
this was added by developer A.
this was added by developer B.
This is because the generated parts are completely independant of each other, thus we just want them to be merged like this.
But, still, when merging we will ALWAYS have to megre it manually, which is not so comfortable in day to day work.
Is there any way to set "default way of merging conflicts in PARTICULAR file" in GIT ?
I was trying to employ git rerere
but it is based on context, which unfortunately changes with every commit. So it can't automatically resolve such conflicts.
I cannot also merge with strategy-option
because I cannot set it to mixed (only mine or theirs chagnes). And it has to be done manually for one particular file.
So what would be the best way?
CONTEXT:
Very simplified, I need a class that returns string with locale-specific string. So I need static properties like:
public static string HelloWorld => _locale == "SPAIN" ? "Hola mundo" : "Hello world";
It says just to return spanish version of a string, when locale is "SPAIN", english version for others.
I have tool, where I type property name and translations (tool helps me finding duplicate names, suggests translations etc.). After that, it defines property automatically. But generated property is always at the end of a file, thus, very easy to get conflicts.
Create a .gitattributes
file with the following content:
myfile.md merge=union
(with the correct filename obviously: it's often helpful if you include one in your question so people answering can refer to it)