When we put Core Data model files under version control with git, we always have a horrible time merging changes - the only sure fire way we\'ve found to avoid having to merge i
While there is no way to get around the merging problem of core data models, I created a git diff driver for core data model files which should make things a bit easier (see README for instructions on how to set it up)
https://github.com/chaitanyagupta/XCDataModelPrinter
Once you've set up XCDataModelPrinter as your git-diff driver, you can do a few things to make merging a bit easier:
Review changes made to the model in our branch
git diff other-branch...my-branch -- /path/to/model
Review changes made to the model in the other branch
git diff my-branch...other-branch -- /path/to/model
After you've reviewed the changes, let's try and do the merge on our branch:
git merge other-branch
If git didn't report a merge conflict, then review the merge results (you will see a combined diff in this case)
git diff --cached /path/to/model
If the merge resulted in a conflict, there's one of two paths you can take: check out the model file in your own branch and manually add changes made to the other one, or vice-versa. Assuming you want to use the first path:
Check out model changes in our own branch:
git checkout --ours -- /path/to/model
Using the diff command above to see the changes made in the other-branch, manually add those changes and review:
git diff -- /path/to/model
Once you are satisfied, just git-add the model file so its no longer marked as unmerged, and commit:
git add /path/to/model
git commit
As soon as you start maintaining migration mapping models, at least you can compare data models and have a look at the changes. The same compare functionality would also be great within SCM revisions of data models and would make life a lot easier.
As far as I have seen, there is no saner way at this time because the model is stored in a format that does not lend itself to merging. Normally I do exactly what you do, have one person working on the model at a time to avoid collisions.