Git、XIB、合并

发布于 2024-10-26 06:00:38 字数 176 浏览 1 评论 0原文

我正要从 master 分支启动一个 git 分支,以向我的应用程序添加一些功能,这也涉及到界面的一些添加。

但是,我已经有一个用于其他一些功能的分支,其中还涉及一些界面添加。

当我完成这些分支后,我能将它们合并到master吗?是否有一些好的做法,可能可以以某种方式构建 xib 文件,以便之后轻松合并?

I was just about to start a git branch off the master branch to add some functionality to my application, that would also involve some additions to the interface.

However, i already have a branch for some other functionality that also involves some interface additions.

Will i be able to merge both those branches to master when i finish with them? Is there some good practice to, probably, structure xib-files in a certain way that would make it easy to merge afterwards?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

你好,陌生人 2024-11-02 06:00:38

例如,如果我在一个分支中有一个包含三个选项卡的选项卡视图,在另一个分支中有一个包含三个选项卡的选项卡视图,并且其中两个选项卡相同,而一个不同,我会得到一个吗?合并后的四选项卡选项卡视图

您很可能会看到 冲突,如果修改行(涉及选项卡定义)相同。
仅当在手动合并解析过程中您错误地留下了额外的选项卡定义时,您才会有 4 个选项卡。

请参阅 Git 中的无痛合并冲突解决 一篇关于合并解析的精彩文章。

3-way merge


话虽这么说,关于xibs 具体来说,它的演示看起来不错:

从 Interface Builder 版本 3 开始,添加了一种新的文件格式(扩展名为 .xib),其功能与 .nib 相同,只不过它存储的是在平面文件中,使其更适合存储在修订控制系统中并通过 diff 等工具进行处理。

但是这个帖子总结了实际的感受:

Git 如何将更改合并到 XIB?
XIB 的结构不是线性的;无法保证您可以只交换 XIB 的部分内容并最终获得可用的 XIB。
除非 Git 对 XIB 的理解接近 Apple,否则我不明白如何合并
保证工作。

在添加合并解决方案(以防发生冲突)之前,您需要执行额外的步骤,在 XCode4 编辑器中打开修改后的 .xib 文件并检查一切是否仍然正常。

XCode4 xib file Editor

完成视觉检查后,通过rerere记录合并解析,您将将来可能会自动解决

What if I, for example, have a tab view with three tabs in one branch, and a tab view with three tabs in the other, and two of the tabs are the same, and one is not, will i get a four-tabbed tab view after the merge

You will most likely have a conflict, if the modified lines (involved in the tab definitions) are the same.
You will have 4 tabs only if, during the manual merge resolution, you mistakingly leave an extra tab definition.

See Painless Merge Conflict Resolution in Git for a great article on merge resolution.

3-way merge


That being said, regarding xibs specifically, its presentation seems good:

As of Interface Builder version 3, a new file format (with extension .xib) has been added, which is functionally identical to .nib, except it is stored in a flat file, making it more suitable for storage in revision control systems and processing by tools such as diff.

But this thread summarizes the actual feeling:

How is Git able to merge changes to XIBs?
The structure of an XIB isn't linear; there's no guarantee that you can just swap out portions of an XIB and wind up with a usable XIB.
Unless Git has an understanding of XIBs near Apple's, I don't see how merging could be
guaranteed to work.

That would leave you with the extra step, before adding your merge resolution in case of conflict, to open the modified .xib file in your XCode4 editor and check if everything still looks good.

XCode4 xib file Editor

Once that visual check is done, record the merge resolution through rerere, and you will have potentially automatic resolution in the future.

握住你手 2024-11-02 06:00:38

当然,您可以将它们合并到 master 中。你如何构建文件并不重要,git 并不关心这一点。

Of course you will be able to merge them both into master. It doesn't matter how you structure your files, git doesn't care about that.

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