Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does git add&remove the Storyboard <classes> section repeatedly?

When saving the storyboard and committing the changes to git, the chances are good that the whole <classes> section will be removed from or added to source control (git). I am using git on the command line, not the XCode integrated UI.

First it looks like this:

+    <classes>
+        <class className="CPTGraphHostingView" superclassName="UIView">
+            <source key="sourceIdentifier" type="project" relativePath="./Classes/CPTGraphHostingView.h"/>
+        </class>
...
+    </classes>

And in the next commit it looks like that:

-    <classes>
-        <class className="CPTGraphHostingView" superclassName="UIView">
-            <source key="sourceIdentifier" type="project" relativePath="./Classes/CPTGraphHostingView.h"/>
-        </class>
...
-    </classes>

Why is that, and, more importantly: how can I stop that?

like image 547
ericteubert Avatar asked Apr 25 '12 10:04

ericteubert


People also ask

Why does git have ADD and commit?

The git add command adds files to the staging area whereas the git commit command will write changes to the repository permanently. When you have completed an important feature, you will need to create a snapshot of that change and save it to the Git repository. To achieve this, you will perform a commit.

Should I always use git add?

The git add command adds new or changed files in your working directory to the Git staging area. git add is an important command - without it, no git commit would ever do anything.

How do I stop git from adding changes?

To undo git add before a commit, run git reset <file> or git reset to unstage all changes. You can read more about other commonly used Git actions in these helpful articles: Git checkout. Git pull vs Git fetch.

Does git add add everything?

The git status command can be used to obtain a summary of which files have changes that are staged for the next commit. The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files.


1 Answers

(this answer is based personal experience, and is not a formal one)

The classes section in the .storyboard xml file lists all the view controllers you have in your project in order to

  1. Allow the Assistant Editor show the right source file when you select a UI element in the Interface Builder, and
  2. Allow the Identity Inspector (right panel) to present options for Custom Class.

I guess this section is a cache, being retired when both of the two uses listed above haven't been used for a while.

The fact that this section turned up in the first place implies it is safe to ignore, since it is auto-generated on need. If you already have it committed, and subsequently have it appear as removed on diff, open the Identity Inspector, drop-down the list of classes available under Custom Class, and see how the whole section exists once again.

like image 54
user1071136 Avatar answered Oct 04 '22 17:10

user1071136