Reputation: 1275
I have a project I have been working on in Xcode 4.4.1, and wanted to go back to a previous Branch. (Note branches are not complex, but represent a linear development)
When I selected the previous branch there was a warning
UserInterfaceState.xcuserstate: warning: Merge conflict: File still marked as conflicted
Everything looked OK, but all the build and run menu items are greyed out, so I can't do anything.
I tried to to revert to the latest branch, and this looks OK, but there is still a Merge conflict MyProject.xcodeproj/project.xcworkspace/xcuserdata/ian.xcuserdatad/UserInterfaceState.xcuserstate: warning: Merge conflict: File still marked as conflicted
I have tried a git status, which did not help
# Unmerged paths:
...
# deleted by them: MyProject.xcodeproj/project.xcworkspace/xcuserdata/ian.xcuserdatad/UserInterfaceState.xcuserstate
#
# Changes not staged for commit:
...
#
# deleted: MyProject.xcodeproj/xcuserdata/ian.xcuserdatad/xcschemes/QuollEyeTree.xcscheme
I tried a git reset HEAD, but this did not seem to help, and I do not know where to go from here.
Git is handy for checking code against previous versions, but I get into trouble whenever I try to swap versions.
My current problems seem to have been exacerbated when I tried to create a workspace and add another project. The original project was created under Xcode 3 and the project and files are immediately under the project directory.
EDIT - Resolved
The answers below did not resolve the issue, but both were helpful.
I saved my code from the project directory, removed the latest branch with
git reset --hard HEAD~1
then copied the changed files back to the project directory
I also updated my .gitignore (which I thought I had done before)
Upvotes: 3
Views: 13681
Reputation: 161
I had the same problem you had after resolving my conflicts and this is how I fixed it. If you use Xcode to keep track of your git repo try the following. 1. I resolved all the conflicts then saved the resolved files. 2. Go to File -> Source Control -> Mark As Resolved
Voila Xcode no longer recognizes these files as having conflicts. Hopefully this works for someone.
Upvotes: 16
Reputation: 7348
Running
git mergetool
and resolving the conflicts fixed the problem for me.
As a side note I use Command-D to navigate to conflicts, pick a side in bottom right hand corner of FileMerge, then Command-S Command-Q (on Mac) once finished to save and quit.
Upvotes: 5
Reputation: 2542
First and foremost, make a good habit of adding *.xcuserstate
and patterns to ignore other user-specific project files to your .gitignore
. There's a popular github repo for .gitignore files, including one for Xcode projects.
In addition to resolving merge conflicts (as mentioned), you should also make a good habit to stash your changes while checkout-ing out different heads (branches, tags, etc).
Upvotes: 1
Reputation: 1664
When there is a merge conflict, you MUST resolve it first. (well maybe you can run git merge --abort
to revert).
So the process is you open your conflicting file, you look for the conflict, resolve it (edit the conflicting lines), then save your file, add it (using git add -u
) and commit it.
Then you can work on a clean work directory.
By the way, a conflict probably looks like:
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
reference: http://www.kernel.org/pub/software/scm/git/docs/git-merge.html
Upvotes: 5