失败的 Xcode Git Merge 卡住了

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10568405/
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-15 00:18:06  来源:igfitidea点击:

Failed Xcode Git Merge is stuck

xcodegitconflict

提问by marciokoko

We have a git based project with a friend and one master branch. He made some changes to some files, I made changes to some other files, and we may, most probably did, make changes to a couple of the same files. He committed and pushed all of his changes to the repo. Then I went and committed my changes and tried to pull his changes. I was presented with a few conflicts which I mostly resolved in favor of his changes because they were files I did not change. Then when I tried to push, I got a fatal: cannot do a partial commit during a merge.

我们有一个基于 git 的项目,有一个朋友和一个主分支。他对一些文件进行了一些更改,我对其他一些文件进行了更改,我们很可能对几个相同的文件进行了更改。他承诺并将他的所有更改推送到 repo。然后我去提交我的更改并尝试拉取他的更改。我遇到了一些冲突,我主要解决了他的更改,因为它们是我没有更改的文件。然后,当我尝试推送时,我得到了一个致命的错误:在合并期间无法进行部分提交。

These are the screens I get.showing the files with source control status

这些是我得到的屏幕。显示具有源代码控制状态的文件

The window when i try to commit

我尝试提交时的窗口

The error message

错误信息

What can I do? The project runs fine except that the main menu of the game isn't showing the images its supposed to, which are the ones he was working on and the class files he worked on, aside from a couple of other ones.

我能做什么?该项目运行良好,除了游戏的主菜单没有显示它应该显示的图像,这些图像是他正在处理的图像和他处理的类文件,除了其他几个。

采纳答案by marciokoko

Xcode has issues with xcuserdata files and I had to discard changes and recommitt

Xcode 有 xcuserdata 文件的问题,我不得不放弃更改并重新提交

回答by Flavien Volken

This is a common frustrating situation:

这是一种常见的令人沮丧的情况:

  1. Open the terminal
  2. Go to your project repository folder (the one containing the .git hidden file)
  3. Move your merge head aside typing mv .git/MERGE_HEAD .git/MERGE_HEAD_STUCK
  1. 打开终端
  2. 转到您的项目存储库文件夹(包含 .git 隐藏文件的文件夹)
  3. 将合并头移到一边打字 mv .git/MERGE_HEAD .git/MERGE_HEAD_STUCK

Your problem should be half solved already, in some case you need to make a pull from the organizer:

你的问题应该已经解决了一半,在某些情况下你需要从组织者那里拉一下:

  1. Open the Organizer - Repositories "File > source control > repositories…"
  2. Find the repository of your project and make a pullfrom here.
  1. 打开管理器 - 存储库“文件 > 源代码控制 > 存储库...”
  2. 找到您项目的存储库并从这里取。

Then you should be able to use Git again from Xcode, you will probably have to resolve some merge conflicts but at least this will be under Xcode and not on the terminal.

然后你应该能够从 Xcode 再次使用 Git,你可能需要解决一些合并冲突,但至少这将在 Xcode 下而不是在终端上。

Note: Consider removing the .DS_Stores from your git repository

注意:考虑从 git 存储库中删除 .DS_Stores

回答by GoZoner

You can't commit until all merge conflicts are resolved. Based on what you described there are files that you both changed. They are conflicts that you must resolve.

在解决所有合并冲突之前,您无法提交。根据您的描述,您都更改了一些文件。它们是您必须解决的冲突。

I've never resolved a conflict in Xcode. You could always resolve the conflict from the Terminal app. Once in a terminal and assuming you've installed the Xcode command line tools try:

我从未解决过 Xcode 中的冲突。您始终可以从终端应用程序解决冲突。一旦进入终端并假设您已经安装了 Xcode 命令行工具,请尝试:

git mergetool
git commit

This will/should pop up a FileMerge window that allows you to select your or his edit. The other option you have from the Terminal is to resolve the conflicts by simply accepting his changes. This will break your code but you can go back and fix it. For that try:

这将/应该弹出一个 FileMerge 窗口,允许您选择您或他的编辑。您从终端获得的另一个选择是通过简单地接受他的更改来解决冲突。这会破坏您的代码,但您可以返回并修复它。对于那个尝试:

git status
git checkout --theirs -- /path/to/a/conflicted/file ...
git add -- /path/to/a/conflicted/file ...
git commit

Then edit the files to fix your functionality. Once all the conflicts are resolved you will be able to commit back in Xcode.

然后编辑文件以修复您的功能。解决所有冲突后,您将能够在 Xcode 中提交。

回答by Thafer Shahin

Open terminal and make use of the following:

打开终端并使用以下命令:

To find which files has conflicts: git status

要查找哪些文件有冲突: git status

To do merge and fix conflicts git mergetool

进行合并和修复冲突 git mergetool

You may need to add some untracked files: git add .

您可能需要添加一些未跟踪的文件: git add .

Finally commit changes git commit

最后提交更改 git commit

回答by Ed Manners

When I have issues with XCode I simply revert to AppCode (trial version if you have to), and doing a commit from the top-level project folder.

当我遇到 XCode 问题时,我只需恢复到 AppCode(如果需要,请使用试用版),然后从顶级项目文件夹进行提交。

AppCode detects the merge scenario, and sorts out the issue with partial Merge. Similarly if AppCode can't sort it out, I use the Github Desktop. Only if all this fails I'll revert to low level commands.

AppCode 检测合并场景,并解决部分合并的问题。同样,如果 AppCode 无法解决,我使用 Github 桌面。只有当所有这些都失败时,我才会恢复到低级命令。

回答by Plexander

I solved this with a completely different approach, using only Xcode's Source Control.

我用完全不同的方法解决了这个问题,只使用了 Xcode 的源代码管理。

Background: Another team Pushed changes to the remote Git repository (via Beanstalk). On my end, the .xcodeproj files came in under different directory, and the changes didn't take. Later, when I tried to commit, I received a Tree Conflict error in Xcode.
Tree Conflict Screenshot

背景:另一个团队将更改推送到远程 Git 存储库(通过 Beanstalk)。最后,.xcodeproj 文件位于不同的目录下,并且没有进行更改。后来,当我尝试提交时,我在 Xcode 中收到了 Tree Conflict 错误。
树冲突截图

Being nearly impossible to correct using Xcode, I replaced the .xcodeproj file with a downloaded version from the Git server. The result... the Xcode project appeared to clear up, however all the updates from the corrupt Pull were showing up as changes I made and were Staged for a Commit. Look at all these Mods and Added filesHowever when trying to Commit, I received the same "fatal: cannot do a partial commit during a merge" error, discussed here.

使用 Xcode 几乎不可能更正,我用从 Git 服务器下载的版本替换了 .xcodeproj 文件。结果...... Xcode 项目似乎清除了,但是来自损坏的 Pull 的所有更新都显示为我所做的更改并且被暂存为提交。查看所有这些 Mod 和添加的文件但是,在尝试提交时,我收到了相同的“致命:在合并期间无法执行部分提交”错误,此处讨论。

Here's how I solved the problem... (Now, understand that I'm a rookie programmer, so I could lack some understanding... but my ignorance led me to find another way to do this.) First, I Cloned my master Branch into a secondary Branch and switched to that branch. Then I created a Working Copy and placed the directory to that working copy outside of the original project directory. (I don't know if this was necessary, but its what I did as I read other troubleshooting techniques.) Then I switched branches to the master, where I realized all my Staged files (changes to Commit) were gone. To make sure all the files were updated to the latest changes made by the other party, I created a new branch called ThirdBranch, which duplicated all files, Pushed it to the Git Server and let Beanstalk compare my server version of the master branch to the ThirdBrach branch I just Pushed (line by line), and all the changes by the other party were present on my Xcode. This meant that my master repository and the Git master repository were the same, which verifies that I solved the problem using Xcode, only.

我是这样解决这个问题的……(现在,明白我是一个菜鸟程序员,所以我可能缺乏一些理解……但我的无知使我找到了另一种方法来做到这一点。)首先,我克隆了我的主人分支到次要分支并切换到该分支。然后我创建了一个工作副本并将目录放置到原始项目目录之外的该工作副本中。(我不知道这是否有必要,但这是我在阅读其他故障排除技术时所做的。)然后我将分支切换到 master,在那里我意识到我所有的 Staged 文件(对 Commit 的更改)都消失了。为了确保所有文件都更新为对方所做的最新更改,我创建了一个名为 ThirdBranch 的新分支,它复制了所有文件,将其推送到 Git 服务器并让 Beanstalk 将我的 master 分支的服务器版本与我刚刚推送的 ThirdBrach 分支(逐行)进行比较,并且对方的所有更改都存在于我的 Xcode 中。这意味着我的主存储库和 Git 主存储库是相同的,这验证了我仅使用 Xcode 解决了问题。

Don't ask me how, beyond what I just described... and certainly fill in the gaps I left out. I'm new at this and I don't understand everything. Maybe an experienced programmer can separate the irrelevant info from the relevant and recreate this technique more clearly, which is in part why I'm posting this.

除了我刚刚描述的内容之外,不要问我如何……并且肯定会填补我遗漏的空白。我是新手,我不明白一切。也许一个有经验的程序员可以将不相关的信息与相关的信息分开,并更清楚地重新创建这种技术,这也是我发布这篇文章的部分原因。