如何明智地处理版本控制和核心数据模型?
当我们使用 git 将 Core Data 模型文件置于版本控制之下时,我们总是会遇到合并更改的可怕时间 - 我们发现避免手动合并更改的唯一可靠方法是在团队之间进行沟通以阻止访问当一个人做出必要的改变并推动时,然后是下一个人,依此类推。 当然有更好的方法来处理这个问题,但作为一个 git 新手,我没有想到明显的解决方案。 有什么建议吗?
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 in changes by hand is to communicate among the team to block off access to the model while one person makes their necessary changes and pushes, then the next person, etc.
Surely there is a better way to handle this, but as a git novice no obvious solution comes to mind.
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一旦开始维护迁移映射模型,至少您可以比较数据模型并查看更改。
相同的比较功能在数据模型的 SCM 修订版中也非常有用,并且会使生活变得更加轻松。
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.
虽然无法解决核心数据模型的合并问题,但我为核心数据模型文件创建了一个 git diff 驱动程序,这应该会让事情变得更容易(有关如何设置它的说明,请参阅自述文件)
https://github.com/chaitanyagupta/XCDataModelPrinter
将 XCDataModelPrinter 设置为 git-diff 驱动程序后,您可以做一些事情可以使合并变得更容易:
检查对我们分支中的模型所做的更改
检查对其他分支中的模型所做的更改 检查更改
后,让我们尝试在我们的分支上进行合并:
如果 git没有报告合并冲突,然后查看合并结果(在这种情况下您将看到合并的差异)
如果合并导致冲突,您可以采取以下两种路径之一:在您自己的分支中检查模型文件并手动添加对另一项所做的更改,反之亦然。假设您想使用第一个路径:
在我们自己的分支中检查模型更改:
使用上面的 diff 命令查看其他分支中所做的更改,手动添加这些更改并查看:
一旦您满意,只需 git-add模型文件,使其不再标记为未合并,并提交:
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
Review changes made to the model in the other branch
After you've reviewed the changes, let's try and do the merge on our branch:
If git didn't report a merge conflict, then review the merge results (you will see a combined diff in this case)
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:
Using the diff command above to see the changes made in the other-branch, manually add those changes and review:
Once you are satisfied, just git-add the model file so its no longer marked as unmerged, and commit: