Question

I have database schema file in repo with always changes. Is there a possiblity to fix conflicts with ours or theirs strategy on merge automatically?

Was it helpful?

Solution

Define a custom merge driver by adding a stanza like the following to your .git/config:

[merge "ours"]
  name = Always take our version
  driver = echo
[merge "theirs"]
  name = Always take their version
  driver = cat %B > %A

The merge driver accepts a number of parameters -- %A is "our" version of the file and %B is "their" version -- and is expected to leave the result of the merge in %A. Hence, the "our" merge driver does nothing, while the "theirs" merge driver can just copy %B over %A.

Now, tell git to use either the ours or theirs merge strategy for your file with a .gitattributes file:

db/schema.rb merge=theirs

# Or:

db/schema.rb merge=ours

OTHER TIPS

You can add this file to .gitignore

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top