Search code examples
gitversion-controlmergexcode4.5

How to permanently remove xcuserdata under the project.xcworkspace and resolve uncommitted changes


I am struggling with a problem with a merge conflict (see Cannot Merge due to conflict with UserInterfaceState.xcuserstate). Based on feedback, I needed to remove the UserInterfaceState.xcuserstate using git rm.

After considerable experimentation, I was able to remove the file with "git rm -rf project.xcworkspace/xcuserdata". So while I was on the branch I was working on, it almost immediately came back as a file that needed to be committed. So I did the git rm on the file again and just switched back to the master. Then I performed a git rm on the file again. The operation again removed the file.

But I am still stuck. If I try to merge the branch into the master branch, it again says that I have uncommitted changes. So I go to commit the change. But this time, it shows UserInterfaceState.xcuserstate as the file to commit, but the box is unchecked and it can't be checked. So I can't move forward. I cannot even switch back to my branch. The file UserInterfaceState.xcuserstate is showing that it is in the "D" state, which obviously means it has been deleted. Is there a way to use 'git rm' to permanently remove xcuserdata under the project.xcworkspace? Should I attempt to put it back into the repository? If so, how.

Help!! Any ideas?

UPDATE:

I paste the result of git status

Changes to be committed:
   modified: project.pbxproj
   modified: [a list of all the files to be merged]

Unmerged paths:
   (use "git add/rm <file>..." as appropriate to mark resolution)
   deleted by us: project.xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcusers‌​tate 
   both modified: ../[projectname]/en.lproj/Localizable.strings

Solution

  • If you deleted the file in the branch, why didn´t you merge your branch into master? that should have been enough.

    I think you might have a conflict because you deleted the file in both branches, that´s why you cannot switch from one to the other: you will not be able to do it until the conflict is resolved. To resolve the conflict for this file, just make a commit since it is marked as deleted (D). If you have other files, check that you don´t skip any new added file when resolving the conflict.

    Also make sure you have a rule in your .gitignore to ignore the xcuserdata file to prevent git from trying to add it again to the index, have a look to this question: gitignore file for xcode projects