Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force git to manual merge even in "obvious" situations

Tags:

git

git-merge

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.

like image 569
filippo Avatar asked Nov 12 '22 22:11

filippo


1 Answers

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.

like image 100
jthill Avatar answered Nov 15 '22 04:11

jthill