I got a problem when I wanted to push source code to remote control. But xcuserstate file was always changed, and Git announce "Commit or discard the changes and try again". So I tried to ignore xcuserstate file but I can't
How can resolve it ???
I got a problem when I wanted to push source code to remote control. But xcuserstate file was always changed, and Git announce "Commit or discard the changes and try again". So I tried to ignore xcuserstate file but I can't
How can resolve it ???
the error-message is pretty specific in what you ought to do: either commit the file (if you want to keep the changes) or discard it (if you don't care about the changes).
the cuser-files are usually hidden deep in the xcode-project, so you might want to provide the full path to them (the following examples use find
to find those files in subdirectories)
this will commit all cuser-files in your current directory:
$ git add $(find . -name "*.xcuserstate" -or -name "*.xcuserdata")
$ git commit $(find . -name "*.xcuserstate" -or -name "*.xcuserdata") -m "updated xcuser stuff"
this will discard changes from all cuser-files in your current directory:
$ git checkout $(find . -name "*.xcuserstate" -or -name "*.xcuserdata")
generally you don't want to track the xcuser-stuff at all, so you should remove it from the repository and make sure it doesn't get added accidentally:
# remove cuser-stuff from the repository (but not locally)
$ git rm --cached $(find . -name "*.xcuserstate" -or -name "*.xcuserdata")
# commit the file removal
$ git commit $(find . -name "*.xcuserstate" -or -name "*.xcuserdata") -m "don't track cuser stuff"
# prevent the cuser-stuff from accidentally adding it
$ echo "*.cuserdata" > .gitignore
$ echo "*.cuserstate" > .gitignore
$ git add .gitignore
$ git commit .gitignore -m "don't track user-specific data"