Xcode says "Uncommitted Changes" Whenever I try to git pull or push

Muhammad Hassan Nasr picture Muhammad Hassan Nasr · Jun 23, 2012 · Viewed 10.7k times · Source

I am using git in my projects, whenever I try to pull from Xcode I get "Uncommitted Changes" and it prevents me from pulling/pushing. I try to commit and find one file with extension *.xcuserstate, this file is modified whenever I open/scroll into any project file in Xcode. That leaves me no option but to do a single commit that contains that file, which fill the git commit logs with meaningless commits.

Is this there is a way to stop this behavior?

I tried to put *.xcuserstate and xcuserdata into git ignore but that caused Xcode to crash every time I try to pull.

This happens with Xcode 4.2 and 4.3

Answer

Greg Hewgill picture Greg Hewgill · Jun 23, 2012

Normally you don't want to put the *.xcuserstate and *.xcuserdata files into your Git repository. These files aren't really part of your project, but are just a place where Xcode stores its local information that is helpful when reloading your project.

You can fix this by using:

git rm --cached *.xcuserstate *.xcuserdata

and then committing the result. This will remove those files from the repository without removing them from your working directory.