Search code examples
swiftxcodegitgitignore

How to add storyboard canvas orientation in git ignore in Xcode


I know this seems really obvious question but I have gone through a lot of different git ignore files but still I am unable to control this one file. What is the issue? enter image description here

enter image description here

How it occurred? I just changed the one view controller's position in the storyboard.

What I need? Any possible way to add this file into git ignore so that I can avoid these simple merge conflicts? Also, I cannot add this storyboard into git ignore because I want to reflect the changes in View Controllers which I actually made. On my previous macbook, it was working fine, no idea why the same git ignore is not working anymore?


Solution

  • Because it's showing "Changes not staged for commit" rather than something about untracked files, what this means is that you have Main.storyboard already being tracked by Git. In other words, as soon as you add a file to Git and commit it, that file becomes tracked, meaning that Git will be monitoring it for changes.

    .gitignore does not work for tracked files, but rather only untracked files. You can use

    git rm --cached Nava/UI/Base.lproj/Main.storyboard
    

    to remove it from the index, and then commit that. Now, if you have the .gitignore file properly set up to ignore that file, you won't see it coming up anymore.