There are a couple answers on how to do it (this and that) suggesting to use a custom driver, which seem quite fine.
However, there is that particular situation when a given file isn't changed in the merged branch so git won't even call the merge driver, but simply overwrite the file.
Is there a way to effectively prevent from happening?
[EDIT]
To clarify, every merge realized contains an excel with the local environment configurations, i.e. every developer's local settings. Such file is rarely edited which normally causes it to be overwritten at every pull I make from the master branch.
Mind that there are some other details in this file which might have been edited and I'd want to update in my own version so it is still important to have it updated. I just wish it always caused a conflict to be manually sorted so I could keep my local configurations and update the rest (even if I had to do it manually).
Also imoprtant to note that this file cannot be split to make my life easier.
git merge drivers exist to efficiently detect and resolve potential conflicts between changes in two histories. Its smudge and clean filters exist to apply and remove changes that are needed only in your worktree, that don't belong in a published history. What you're doing is a smudge, a local-only change nobody else needs. merge is a conflict-resolver, not a smudger.
You've already got the code to apply your local changes even if nothing else has changed upstream, you can run that as a smudge filter directly by feeding it the same file as both inputs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With