1

我正在努力解决合并冲突的问题(请参阅由于与 UserInterfaceState.xcuserstate 冲突而无法合并)。根据反馈,我需要使用 git rm 删除 UserInterfaceState.xcuserstate。

经过大量实验,我能够使用“git rm -rf project.xcworkspace/xcuserdata”删除该文件。因此,当我在我正在处理的分支上时,它几乎立即作为需要提交的文件返回。所以我再次对文件执行了 git rm 并切换回主控。然后我再次对文件执行了 git rm 。该操作再次删除了该文件。

但我仍然卡住了。如果我尝试将分支合并到主分支,它再次表示我有未提交的更改。所以我去提交改变。但这一次,它显示 UserInterfaceState.xcuserstate 为要提交的文件,但该框未选中,无法选中。所以我无法前进。我什至无法切换回我的分支。文件 UserInterfaceState.xcuserstate 显示它处于“D”状态,这显然意味着它已被删除。有没有办法使用'git rm'永久删除project.xcworkspace下的xcuserdata?我应该尝试将其放回存储库吗?如果是这样,如何。

帮助!!有任何想法吗?

更新:

我粘贴 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
4

2 回答 2

2

这是我从提交中删除 xcuserdata/xcuserstate 的步骤

1- 从这里生成 .gitignore: https ://www.toptal.com/developers/gitignore

2- 使用终端将 .gitignore 添加到项目中:

  • 在终端导航到项目根文件并键入:touch .gitignore

3- 转到项目文件夹中的文件,打开它,然后粘贴在第一步中生成的代码。

4-仍在项目类型中的终端中git add .gitignore

5- 同样在终端中,通过键入以下命令从 git 中删除 xcuserstate:git rm <whole path to xcuserstate>

如果您不知道路径,git status请从那里键入并复制整个 xcuserstate 路径。

6- 在 Xcode 中提交,您不应该看到 xcuserstate 文件,因为您.gitignore分别在步骤 2 和 5 中从 git 中添加和删除了它。

于 2021-06-29T08:40:11.607 回答
1

如果您删除了分支中的文件,为什么不将您的分支合并到 master 中?这应该已经足够了。

我认为您可能会发生冲突,因为您删除了两个分支中的文件,这就是为什么您无法从一个分支切换到另一个:在冲突解决之前您将无法执行此操作。要解决此文件的冲突,只需提交一次,因为它被标记为已删除 (D)。如果您有其他文件,请检查在解决冲突时是否跳过任何​​新添加的文件。

还要确保你的 .gitignore 中有一条规则来忽略 xcuserdata 文件,以防止 git 尝试再次将其添加到索引中,看看这个问题:gitignore file for xcode projects

于 2012-12-15T20:04:06.943 回答