5

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.

Community
  • 1
  • 1
filippo
  • 5,583
  • 13
  • 50
  • 72
  • What are you actually trying to achieve here? What git's doing is causing you some difficulty, please describe the situation and the difficulty. – jthill Sep 08 '13 at 22:44
  • I will add some description to clarify, but basically I am having issues with binary files (excel) containing local configurations. – filippo Sep 09 '13 at 12:51
  • Related: http://stackoverflow.com/q/9703633/1248008 – Jonas Schäfer Sep 09 '13 at 13:18
  • How do you want to merge a file if there are no changes? That's not a merge then … – knittl Sep 09 '13 at 13:40
  • 1
    @knittl Well, there were no changes from my side, but there are still incoming changes - for which I want only a port of... – filippo Sep 09 '13 at 13:54
  • [Here's an example](http://stackoverflow.com/questions/15150317/git-ignoring-a-specific-modification-to-a-config-file/15936382#15936382) of how to do that for text files. [Here's links to the Office file formats](http://www.joelonsoftware.com/items/2008/02/19.html), good luck with that. – jthill Sep 09 '13 at 17:10
  • @jthill yeah... not doing those. wish I could just always manually merge :( – filippo Sep 10 '13 at 14:49

1 Answers1

1

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.

jthill
  • 55,082
  • 5
  • 77
  • 137