Can't ignore UserInterfaceState.xcuserstate

后端 未结 12 2137
既然无缘
既然无缘 2020-12-22 14:08

I\'m using Git for Xcode 4 project version control. I\'ve explicitly added ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterface

相关标签:
12条回答
  • 2020-12-22 14:47

    In case that the ignored file kept showing up in the untracked list, you may use git clean -f -d to clear things up.

    1.

    git rm --cached {YourProjectFolderName}.xcodeproj/project.xcworkspace/xcuserdata/{yourUserName}.xcuserdatad/UserInterfaceState.xcuserstate
    

    2.

    git commit -m "Removed file that shouldn't be tracked"
    

    3. WARNING first try git clean -f -d --dry-run, otherwise you may lose uncommited changes.

    Then: git clean -f -d

    0 讨论(0)
  • 2020-12-22 14:47

    Just "git clean -f -d" worked for me!

    0 讨论(0)
  • 2020-12-22 14:50

    In case the file keeps showing up even after doing everything mentioned here, make sure that this checkbox in Xcode settings is unchecked:

    0 讨论(0)
  • 2020-12-22 14:54

    For xcode 8.3.3 I just checked tried the above code and observe that, now in this casewe have to change the commands to like this

    first you can create a .gitignore file by using

     touch .gitignore
    

    after that you can delete all the userInterface file by using this command and by using this command it will respect your .gitignore file.

     git rm --cached [project].xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate
     git commit -m "Removed file that shouldn't be tracked"
    
    0 讨论(0)
  • 2020-12-22 14:55

    For me nothing worked, but this

    add this line to your gitignore

    *.xcuserdata
    
    0 讨论(0)
  • 2020-12-22 14:56

    Git is probably already tracking the file.

    From the gitignore docs:

    To stop tracking a file that is currently tracked, use git rm --cached.

    Use this, replacing [project] and [username] with your info:

    git rm --cached [project].xcodeproj/project.xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate
    git commit -m "Removed file that shouldn't be tracked"
    

    Alternatively you can use the -a option to git commit that will add all files that have been modified or deleted.

    Once you've removed the file from git, it will respect your .gitignore.

    0 讨论(0)
提交回复
热议问题