Git, XIBs, merging

MacOS

Question or issue on macOS:

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?

How to solve this problem?

Solution no. 1:


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.

Solution no. 2:

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.

Hope this helps!