Can't ignore UserInterfaceState.xcuserstate
Solution 1
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
.
Solution 2
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
Solution 3
All Answer is great but here is the one will remove for every user if you work in different Mac (Home and office)
git rm --cache */UserInterfaceState.xcuserstate
git commit -m "Never see you again, UserInterfaceState"
Solution 4
Had a friend show me this amazing site https://www.gitignore.io/. Enter the IDE of your choice or other options and it will automatically generate a gitignore
file consisting of useful ignores, one of which is the xcuserstate
. You can preview the gitignore
file before downloading.
Solution 5
In case the file keeps showing up even after doing everything mentioned here, make sure that this checkbox in Xcode settings is unchecked:
Comments
-
GarlicFries almost 2 years
I'm using Git for Xcode 4 project version control. I've explicitly added
ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate
to.gitignore
, but Git it won't ignore it. Any ideas why this is so? -
Rob Caraway over 11 yearsI have this problem but when I try to remove the xcuserstate file it says 'did not match any files'. Whats going on?
-
MaxGabriel almost 11 yearsI have the same problem as @RobCaraway
-
Brainware almost 11 yearsThis helped me: 1) quit xcode; 2) go to the project directory and do an "ls -la" from the terminal app to make sure you see the .git and .gitignore files; 3) change "ProjectFolder" in the example above to the name of your project; 4) do the two git commands that matt shows; 5) Relaunch XCode and do a commit and verify that the xcuserstate file is no longer listed.
-
bpn about 10 yearsAny idea how to do the equivalent in svn? I am getting the same issue, wherein svn is not ignoring the file
-
Jay Versluis about 10 yearsThank you @Brainware!! It finally worked thanks to your suggestion. I think closing Xcode beforehand is very important.
-
cspam about 9 yearsgithub now gives you a default .gitignore file that includes this file among others but you still have to go through your steps. kind of annoying
-
trdavidson almost 9 years@matt just went through these steps but still have the same isse..also tried the commit -a option with no luck. Any suggestions?
-
Jeremy Luisetti over 8 yearsThanks men, git clean -f -d just deleted . xcodeproj and other files from my project...
-
zero0cool about 6 yearsIt's strongly advised to use the --dry-run flag before running git clean, i.e.
git clean -f -d --dry-run
to see what happens -
MEnnabah almost 6 yearsIs it possible to make the
[username]
variables based on the machine? It would be helpful when working with a team! -
Bhavin_m about 5 yearsPlease help for the SVN subversion for the same.
-
allenlinli about 5 yearsWhat does
git clean -f -d
do? -
kalafun about 5 yearsDon't use the
git clean -f -d
if you have uncommitted files changes! I used it and it removed my freshly created files with content already created! :) So first commit and then clean -
Manish almost 5 years@All those who have issue of 'did not match any files', you can go to .xcodeproj show packages, then you can see xcuserdata, you can delete from there. and then commit.
-
Felecia Genet over 3 yearsI also was getting did not match any files. For whatever reason I had to use the full path: /Users/[USERNAME AS SEEN IN TERMINAL]/Desktop/[MY DEV PROJECTS FOLDER]/[MY XCODE PROJECT FOLDER]/[MY PROJECT NAME].xcworkspace/xcuserdata/[USERNAME AS SEEN IN TERMINAL].xcuserdatad/UserInterfaceState.xcuserstate