xcode Git、XIB、合并

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5435543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 20:39:06  来源:igfitidea点击:

Git, XIBs, merging

xcodegitmacosxib

提问by Ibolit

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.

我正要从 master 分支开始一个 git 分支,为我的应用程序添加一些功能,这也将涉及对界面的一些添加。

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?

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

采纳答案by VonC

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 modifiedlines (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.

如果修改后的行(涉及选项卡定义)相同,则很可能会发生冲突。 只有在手动合并解决期间,您错误地留下了额外的选项卡定义,您才会拥有 4 个选项卡。

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

有关合并解决的精彩文章,请参阅Git中的无痛合并冲突解决

3-way merge

三路合并



That being said, regarding xibsspecifically, its presentation seems good:

话虽如此,特别是关于xibs,它的介绍似乎很好:

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.

从 Interface Builder 版本 3 开始,添加了一种新的文件格式(带有扩展名.xib.nib,除了存储在平面文件中之外,它在功能上与 .差异。

But this threadsummarizes 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.

Git 如何能够合并对 XIB 的更改?
XIB 的结构不是线性的;不能保证您可以只换出 XIB 的一部分并最终获得可用的 XIB。
除非 Git 了解 Apple 附近的 XIB,否则我看不出如何保证合并工作。

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

这会给你留下额外的步骤,在冲突的情况下添加你的合并解决方案之前,.xib在你的 XCode4 编辑器中打开修改后的文件并检查一切是否仍然看起来不错。

XCode4 xib file Editor

XCode4 xib 文件编辑器

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

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

回答by ralphtheninja

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.

当然,您将能够将它们都合并到 master 中。你如何组织你的文件并不重要,git 不在乎。