简体   繁体   English

梦魇试图解决 Xcode 项目上的 git 冲突

[英]Nightmare trying to solve a git conflict on a Xcode project

I am new to git.我是 git 的新手。 I know the basic stuff and very badly.我知道基本的东西,而且非常糟糕。

A few days ago I have branched from a master remote to create a branch called coreData .几天前,我从主远程分支创建了一个名为coreData的分支。

Other stuff have been merged into the remote master.其他东西已合并到远程主机中。 So, the remote master is ahead of the master I have used to branch.因此,远程 master 领先于我曾经分支的 master。

Now I have coreData finished.现在我已经完成了coreData I want to open a pull request on that, so it can be merged into the master.我想对此打开一个拉取请求,以便它可以合并到主控中。

I have tried the little I know to solve that.我已经尝试了我所知道的一点点来解决这个问题。

What I have did so far.到目前为止我所做的。

Make my local master equal to remote master使我的本地主机等于远程主机

  • git checkout master git 结账主控
  • git pull git拉

then然后

  • git checkout coreData git 结帐 coreData
  • git rebase master git rebase master

also tried也试过

  • git checkout coreData git 结帐 coreData
  • git merge master git 合并主控

in both cases I solved all conflicts, but the results are not what they should be.在这两种情况下,我都解决了所有冲突,但结果却不是应该的。

I think my big problem is the .xcodeproj .我认为我的大问题是.xcodeproj

This is something I do not understand for the xcodeproj .这是我对xcodeproj不理解的事情。 See the image below:见下图:

在此处输入图像描述

This conflict is impossible.这种冲突是不可能的。 It tells me that one line is replacing all the blue block.它告诉我一行正在替换所有蓝色块。 It is impossible.是不可能的。 In cases like that I accept both, but the final xcodeproj becomes corrupt or incorrect.在这种情况下,我两者都接受,但最终的xcodeproj会损坏或不正确。

Is there a way to solve that?有没有办法解决这个问题? If you need more info, please ask and I'll post.如果您需要更多信息,请询问,我会发布。

I can't speak specifically to xcode project files, however, auto generated project files are often one of the most difficult types of (text-based) files to resolve using merge conflict functionality.我不能专门谈论 xcode 项目文件,但是,自动生成的项目文件通常是使用合并冲突功能解决的最困难的(基于文本的)文件类型之一。 Sometimes, when both sides have just added new things, it is as easy as accepting both sides.有时候,当双方都加入了新的东西时,就像接受双方一样容易。 Unfortunately, as you are witnessing, that doesn't always work.不幸的是,正如您所看到的,这并不总是有效。 Essentially you are trying to manually edit a file that is auto-generated, and sometimes the file has expectations and/or ordering rules that you may not be able to manually re-create without knowing the exact details of how the file is generated.本质上,您正在尝试手动编辑自动生成的文件,有时该文件具有预期和/或排序规则,您可能无法在不知道文件如何生成的确切细节的情况下手动重新创建。

When this sort of thing happens to me, I typically take a stab at it, and then I create a new branch off of the updated target branch, re-do just my project level changes, and take a look at the newly created project file.当这种事情发生在我身上时,我通常会尝试一下,然后从更新的目标分支创建一个新分支,重新进行我的项目级别更改,然后查看新创建的项目文件. You may be able to simply copy that version of the project file into your other (almost-working) branch and be good to go.您可以简单地将该版本的项目文件复制到您的另一个(几乎可以工作的)分支中,并且对 go 很好。 Comparing them in this way may also help pinpoint where your merge went wrong.以这种方式比较它们也可能有助于查明您的合并出错的地方。 Oftentimes it's a missing or incorrect GUID somewhere.通常是某个地方缺少或不正确的 GUID。

Side note: you can save a few steps in your workflow by skipping checking out master .旁注:您可以通过跳过检出master来节省工作流程中的几个步骤。 Instead, with your branch checked out, you can just:相反,签出您的分支后,您可以:

git fetch
git rebase origin/master

You can even delete your local copy of master , and from now on, create new branches off of origin/master , and use the same when rebasing or merging.您甚至可以删除master的本地副本,从现在开始,从origin/master创建新的分支,并在变基或合并时使用相同的分支。 Every time you git fetch you'll update your copy of origin/master .每次您git fetch时,您都会更新您的origin/master副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM