0

So I stashed my changes for my Swift project so that I could make a pull request and then merge the changes I made with the new pull. However, whenever I try to merge my changes I get a merge conflict, regarding the UserInterfaceState.xcuserstate XCode file. Nothing I'm trying is allowing me to merge my stashed code, and I'm worried that I'm going to lose an afternoon's worth of code.

I tried adding *.xcuserstate to .gitignore, but that didn't seem to do anything. I then tried deleting the file, which created a modify/delete conflict from the version in the stash. Here's the error I'm getting when I try to get the stashed code:

$ git stash apply
CONFLICT (modify/delete): myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate left in tree.

Trying what Flows recommended this was the output I received:

$ git reset --hard
HEAD is now at e509ffa Fixed bugs
$ git stash pop
myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate: needs merge
unable to refresh index

$ git rm myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate
myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate: needs merge
rm 'myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate'
$ git stash pop
CONFLICT (modify/delete): myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate left in tree.

Is there anything that I can do to fix this? Nothing seems to be working, so any help would be greatly appreciated, thanks.

shadowarcher
  • 3,265
  • 5
  • 21
  • 33
  • Is the change to the file in question needed? Or should it be removed like it has been upstream? If it is not needed, after applying your stash and seeing the conflict, delete the file from your file system, run: `git rm ` and commit the changes. – Andonaeus May 26 '16 at 14:17
  • Do you have unmerged file ? See this link : [unable to refresh index](http://stackoverflow.com/questions/9739352/git-stash-pop-needs-merge-unable-to-refresh-index). Be sure your working tree is clean using `git status`. If not, resolve and commit conflict before doing again the stash pop – Flows May 26 '16 at 14:18
  • @Andonaeus I tried to remove the file, but it ended up causing a modify/delete conflict. I posted the response in my original post. – shadowarcher May 26 '16 at 14:35
  • @shadowarcher you should have removed the file after applying your stash. – Andonaeus May 26 '16 at 14:36
  • @shadowarcher : Did you try to solve conflict and commit after your last edit ? – Flows May 26 '16 at 14:37

1 Answers1

1

You can try this

Reset master with --hard option to origin/master

Apply the stash with stash pop

Git should tell you there is a conflict. Edit UserInterfaceState.xcuserstate file to see the conflict and correct it.

git commit

If it doesn't work, could you paste all git output of the commands ?

Flows
  • 3,675
  • 3
  • 28
  • 52