title: Git, how to set .gitattributes for Storyboards and .xib files
body: <p><strong>Background</strong>: git -- or any other SCM -- can "successfully" merge Storyboards, xib's, and pbxproj files as at their core they are just xml. Sometimes there are conflicts which can be resolved by the usual conflict resolution strategies. But xib's and Storyboards are serialized formats of some pretty complex data structures, so the fun begins.</p>
  
  <p>Just as with other source code, a successful merge doesn't guarantee all the merged changes work correctly together. With the files in question, git can successfully merge but Xcode sometimes displays a "Could not read archive" error when you try to open it - i.e., the merge corrupted the xib.</p>
  
  <p>I've seen suggestions about having git ignore .xibs (not practical), or in .gitattributes disable diff by setting</p>
  
  <pre><code>*.xib -crlf -diff
  </code></pre>
  
  <p>Technically, that fixes the merge conflict/corrupted xib problem - but now somebody's changes are lost? </p>
  
  <p>Similarly, the best recommendation I've seen for the project file is merge=union in .gitattributes:</p>
  
  <pre><code>*.pbxproj merge=union
  </code></pre>
  
  <p><strong>Question</strong>: I've searched quite a bit and there doesn't seem to be a good solution. Can people with experience tell me what happens in a few use cases?</p>
  
  <ol>
  <li><p>In the project I rename a file from x to y, and delete fileA. Meanwhile, another programmer committed changes to add fileC and delete fileD. What is the result of merge? I'm sure the actual file system changes will be correct, but in the Xcode navigator panel:</p>
  
  <ul>
  <li>Will I see both x and Y? </li>
  <li>Will fileA reappear because it's still in the other programmer's .pbxproj? </li>
  <li>Will fileD still be there because it's still in my .pbxproj?</li>
  </ul></li>
  <li><p>If git is ignoring .xib files - will I at least get a warning that a file was changed and is not being handled?</p></li>
  </ol>