Can't exclude user interface state from commit in xcode

I can’t exclude user interface state file from commit.

Every time I’m trying to push to github it asks me to commit first and insert user interface state file into the changes (even if I didn’t move the mouse or interface at all it still is shown to commit!).

  • Do you push every single commit?
  • Git error on commit after merge - fatal: cannot do a partial commit during a merge
  • How to get a list of all Subversion commit author usernames?
  • How to make a git rebase and keep the commit timestamp?
  • git - Your branch is ahead of 'origin/master' by 1 commit
  • How to write git commit messages for submodule updates?
  • I tried different methods, described in other similar topics. For example, I tried to add all possible cases of user interface into the .gitignore in root, like this:

    *.xcuserstate
    project.xcworkspace
    xcuserdata
    UserInterfaceState.xcuserstate
    project.xcworkspace/
    xcuserdata/
    UserInterface.xcuserstate
    

    It didn’t work.
    I tried to clean the cache and reset git, didn’t help.

    Git status command says the following: “modified: .xcodeproj/project.xcworkspace/xcuserdata/.xcuserdatad/UserInterfaceState.xcuserstate”

    And it looks like this

    Please help (it is driving me crazy)!

  • Using `git checkout -b` with and without a branch starting point
  • git push origin master fails
  • How can I get a git submodule's associated commit ID from a past commit in the parent clone?
  • Git Svn dcommit error - restart the commit
  • Open a file directly from a GitLab private repository
  • Capistrano 3 pulling command line arguments
  • 2 Solutions collect form web for “Can't exclude user interface state from commit in xcode”

    If those files are already committed, you need to remove them from the index before seeing your .gitignore file work.

    git rm --cached *.xcuserstate
    # or
    git rm -r --cached project.xcworkspace
    

    To add on to VonC’s answer after calling -rm you also have to commit and then push (do this in the terminal BEFORE touching Xcode or it’s git tools again), that solved my problem.

    So

    git rm --cached *.xcuserstate
    git commit -m "Removed cached files"
    git push
    

    Then you can touch Xcode again

    Git Baby is a git and github fan, let's start git clone.