Search code examples
iosxcodeversion-controlxcode13

Xcode Source Control doesnt track the changes


When I add a new file to xcode, sometimes it's source control doesnt track the changes of the newly added file. I can see the changes in SourceTree but not in xcode.

On below image, I should see a blue bar near the red area I marked. But I can't. This happens sometimes to newly added files only.

File Screenshot

What I've tried so far are as below:

  • CLosing&Reopening xcode and macbook.
  • Adding untracked files from xcode source control toolbar as below image:

enter image description here

As you see the files seem already be added to source control. What can I do to see that blue bar near those lines numbers again?

enter image description here Why is this happening? Note: This only happens to newly added file currently.


Solution

  • It's explained on this page.

    In Xcode, you can save your project’s current state in a commit, navigate the history of your project’s previous commits, compare changes between specific commits, and quickly restore to a previous commit. ... The Project navigator annotates files with changes since the last commit, using an A for new files or an M for modified files. ... The comparison view highlights changes between the current source code and the most recent commit.

    So as you see tracking is comparing to "last commit". If "last commit" did not contain this file, then tracking will only tell you "the file was added" (A in the tree). So in order to see changes in newly added file, commit immediately after you add a file, so next time you modify it, the letter in the tree is M and you see the changes since last commit.