0

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
Community
  • 1
  • 1
JeffB6688
  • 3,752
  • 4
  • 36
  • 57

1 Answers1

0

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

Community
  • 1
  • 1
aalbagarcia
  • 975
  • 6
  • 17
  • But that is the problem. Even though it is marked as deleted, the check box next to it is unchecked and cannot be checked. Consequently, the button that says Commit Files is greyed out. Regarding the .gitignore, I have xcuserdata, *.xcuserstate, and project.xcworkspace/ in the rules. But it doesn't seem to do anything. – JeffB6688 Dec 16 '12 at 00:35
  • Can you add the result of running the command git status to your question? – aalbagarcia Dec 16 '12 at 05:57
  • aag, I was able to run git -commit to commit that file. That allowed me to go back to xcode to attempt a merge. The merge failed with an error that I failed to capture, but was something like "failed to merge. xcode will not overwrite...". I think it was referring to the UserInterfaceState.xcuserstate existing on the branch is some state. So then I quit the merge and tried to switch to the branch. Again it failed due to uncommitted changes on the master branch. I then saw that all of the files that are to be merged are listed as needing to be committed (strange) including – JeffB6688 Dec 16 '12 at 14:10
  • including UserInterfaceState.xcuserstate. If I try to commit, it won't let me stating: fatal: cannot do a partial commit during a merge. Again, the files waiting to be committed are the one belonging to the branch. UserInterfaceState.xcuserstate is marked in the D state and the reset in the M state. Do you recommend any git command I can execute to push this merge through? Thanks for any help – JeffB6688 Dec 16 '12 at 14:14
  • regarding your request for a git status, here is the result: git status # On branch master # Changes to be committed: # # modified: project.pbxproj # modified: [a list of all the files to be merged] # # Unmerged paths: # (use "git add/rm ..." as appropriate to mark resolution) # # deleted by us: project.xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcuserstate # both modified: ../[projectname]/en.lproj/Localizable.strings So again, do you recommend any git command I can execute to push this merge through? – JeffB6688 Dec 16 '12 at 17:04
  • @JeffB6688 As you can see from the message, you have an incomplete merge because you have a conflict. You should git rm project.xcworkspace/xcuserdata/[username].xcuserdatad/UserInterfaceState.xcusers‌​tate and resolve the conflict in file [projectname]/en.lproj/Localizable.strings. Open it and search for <<<< or ===== to see what the conflict is. After you resolve the conflict do a git add ..Localizable.strings and then commit to close the merge. – aalbagarcia Dec 16 '12 at 20:22
  • So that I don't screw this up, how do I deal with [projectname]/en.lproj/Localizable.strings. On the master branch, I only added a space to the file because I was experimenting. I don't want the change that I made. There is no conflict file. Should I do a git rm on it? Or is there another command. I only care about the changes I made on the working branch. But even those are not that difficult to recreate, so I don't mind if it gets screwed up. – JeffB6688 Dec 17 '12 at 02:23
  • You can checkout the file in the working branch by running git checkout --theirs [projectname]/en.lproj/Localizable.strings. Open the file to check that your changes in the master branch have been overwritten and then run git add [projectname]/en.lproj/Localizable.strings Then git add the rest of the files and run git commit to close the merge. This question can be useful [this question](http://stackoverflow.com/questions/928646/how-do-i-tell-git-to-always-select-my-local-version-for-conflicted-merges-on-a-s/930495#930495) – aalbagarcia Dec 17 '12 at 20:56
  • I tried to perform a git checkout, but it failed with: error: path '[projectname]/en.lproj/Localizable.strings' is unmerged. So I had no choice but to do a git rm on the file. This put it in the deleted state. Now I had 20 modified files from the working branch and this 1 deleted file. I still was unable to use the xcode UI to complete this merge. So I used git commit to commit all files. This essentially caused the merge to occur. I now have everything merged on the master branch. I then had to reconstruct the Localizable.strings file. Everything built successfully. Thanks for the help – JeffB6688 Dec 17 '12 at 21:40