如何明智地处理版本控制和核心数据模型?

发布于 2024-09-07 16:43:46 字数 176 浏览 4 评论 0原文

当我们使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情话已封尘 2024-09-14 16:43:55

一旦开始维护迁移映射模型,至少您可以比较数据模型并查看更改。
相同的比较功能在数据模型的 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.

↙温凉少女 2024-09-14 16:43:53

据我所知,目前没有更明智的方法,因为模型以不适合合并的格式存储。通常我会按照你的做法做,一次让一个人处理模型以避免碰撞。

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.

蛮可爱 2024-09-14 16:43:51

虽然无法解决核心数据模型的合并问题,但我为核心数据模型文件创建了一个 git diff 驱动程序,这应该会让事情变得更容易(有关如何设置它的说明,请参阅自述文件)

https://github.com/chaitanyagupta/XCDataModelPrinter

将 XCDataModelPrinter 设置为 git-diff 驱动程序后,您可以做一些事情可以使合并变得更容易:

检查对我们分支中的模型所做的更改

git diff other-branch...my-branch -- /path/to/model

检查对其他分支中的模型所做的更改 检查更改

git diff my-branch...other-branch -- /path/to/model

后,让我们尝试在我们的分支上进行合并:

git merge other-branch

如果 git没有报告合并冲突,然后查看合并结果(在这种情况下您将看到合并的差异)

git diff --cached /path/to/model

如果合并导致冲突,您可以采取以下两种路径之一:在您自己的分支中检查模型文件并手动添加对另一项所做的更改,反之亦然。假设您想使用第一个路径:

在我们自己的分支中检查模型更改:

git checkout --ours -- /path/to/model

使用上面的 diff 命令查看其他分支中所做的更改,手动添加这些更改并查看:

git diff -- /path/to/model

一旦您满意,只需 git-add模型文件,使其不再标记为未合并,并提交:

git add /path/to/model
git commit

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文