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

11,039

Solution 1

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.

Solution 2

If this is a settings file which is different for every developer, you probably don't need to version control it, just remove it from Git.

If that is not an option, you can Git Stash Save your changes before pulling and Git Stash pop to apply them again.

Share:
11,039
Muhammad Hassan Nasr
Author by

Muhammad Hassan Nasr

Updated on June 04, 2022

Comments

  • Muhammad Hassan Nasr
    Muhammad Hassan Nasr almost 2 years

    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

  • Muhammad Hassan Nasr
    Muhammad Hassan Nasr almost 12 years
    I tried to put them in gitignore but Xcode crash when I try to pull, does this happen with you?
  • Muhammad Hassan Nasr
    Muhammad Hassan Nasr almost 12 years
    I tried to put them in gitignore but Xcode crash when I try to pull, does this happen with you, did you try that method?
  • Greg Hewgill
    Greg Hewgill almost 12 years
    No, it doesn't. Is Xcode running when you pull? Perhaps try closing Xcode first.
  • Muhammad Hassan Nasr
    Muhammad Hassan Nasr almost 12 years
    I will try it with my team and accept the answer if it worked OK.
  • Usman
    Usman almost 12 years
    No, personally I never put configuration files under source control. Did you try to stash them instead?
  • Muhammad Hassan Nasr
    Muhammad Hassan Nasr almost 12 years
    I tried your solution and .xcuserstate files are now untracked. Everytime I try to pull from Xcode it crashes. The only solution stopped it from crashing is to add and commit .xcuserstate files again...
  • Paul Brewczynski
    Paul Brewczynski over 10 years
    Wouldn't it be nice to stop track them at all ? It is pretty annoying that every time you commit "something in the interface of Xcode" changes... And this file changes...