Git 帮助 UserInterfaceState.xcuserstate:警告:合并冲突:文件仍标记为冲突

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12192649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:26:40  来源:igfitidea点击:

Git Help UserInterfaceState.xcuserstate: warning: Merge conflict: File still marked as conflicted

gitxcode4

提问by Milliways

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)

我有一个我一直在 Xcode 4.4.1 中工作的项目,并想回到以前的分支。(注意分支并不复杂,但代表线性发展)

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

我试图恢复到最新的分支,这看起来不错,但仍然存在合并冲突 MyProject.xcodeproj/project.xcworkspace/xcuserdata/ian.xcuserdatad/UserInterfaceState.xcuserstate:警告:合并冲突:文件仍然标记为冲突

I have tried a git status, which did not help

我尝试了 git status,但没有帮助

# 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 reset HEAD,但这似乎没有帮助,我不知道从哪里开始。

Git is handy for checking code against previous versions, but I get into trouble whenever I try to swap versions.

Git 可以方便地根据以前的版本检查代码,但是每当我尝试交换版本时都会遇到麻烦。

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.

当我尝试创建一个工作区并添加另一个项目时,我当前的问题似乎更加严重。原始项目是在 Xcode 3 下创建的,项目和文件直接位于项目目录下。

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)

我还更新了我的 .gitignore (我以为我以前做过)

回答by djm

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

我在解决冲突后遇到了与您相同的问题,这就是我解决的方法。如果您使用 Xcode 来跟踪您的 git repo,请尝试以下操作。1.我解决了所有冲突,然后保存了解决的文件。2. 转到文件 -> 源代码管理 -> 标记为已解决

Voila Xcode no longer recognizes these files as having conflicts. Hopefully this works for someone.

瞧 Xcode 不再将这些文件识别为有冲突。希望这对某人有用。

回答by Vince

When there is a merge conflict, you MUST resolve it first. (well maybe you can run git merge --abortto revert).

当出现合并冲突时,您必须首先解决它。(好吧,也许你可以跑git merge --abort回去恢复)。

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.

所以这个过程是你打开你的冲突文件,你查找冲突,解决它(编辑冲突行),然后保存你的文件,添加它(使用git add -u)并提交它。

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

参考:http: //www.kernel.org/pub/software/scm/git/docs/git-merge.html

回答by Matt Hudson

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.

作为旁注,我使用 Command-D 导航到冲突,在 FileMerge 的右下角选择一侧,然后 Command-S Command-Q(在 Mac 上)完成保存并退出。

回答by hlfcoding

First and foremost, make a good habit of adding *.xcuserstateand 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.

首先,养成*.xcuserstate.gitignore. 有一个用于 .gitignore 文件的流行 github 存储库,包括一个用于 Xcode 项目的存储库。

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).

除了解决合并冲突(如上所述)之外,您还应该养成一个好习惯,在检出不同的 head(分支、标签等)时隐藏您的更改。