简体   繁体   English

Xcode:在GIT子分支中添加了文件,现在尝试合并向上给定,“树冲突”

[英]Xcode: Added file in GIT sub-branch, now attempts to merge upward give, “Tree Conflict”

I'm only using a local repository with Xcode 8.2.1. 我只在Xcode 8.2.1中使用本地存储库。 It's a one-man show, I'm the only one making code changes. 这是一个单人表演,我是唯一更改代码的人。 Over the years, I created a series of sub-branches in GIT as follows: 多年来,我在GIT中创建了一系列子分支,如下所示:

master
     branch1
     ...
     branch14
            branch14.1
            ...
            branch 14.13    //added lots of new code/classes
                   branch 14.13.NewCombatReports //refactor 1 class into 2

In 14.13 I added quite a few new classes by using xcode's "New File" option and creating new classes. 在14.13中,通过使用xcode的“新建文件”选项并创建了新类,我添加了很多新类。 Once I had things functional, I created a sub branch, 14.13.NewCombatReports, to isolate refactoring one of the larger classes (separating a large chunk of code into it's own, new class, BattleManager.m/h). 使功能正常运行后,我创建了一个子分支14.13.NewCombatReports,以隔离重构较大的类之一(将大量代码分离到自己的新类BattleManager.m / h中)。

When I was satisfied, I committed the changes, then attempted to merge into the parent branch. 当我感到满意时,我提交了更改,然后尝试合并到父分支中。 I received an error saying: 我收到一条错误消息:

The operation could not be performed because of one or more tree conflicts. 由于一棵或多棵树冲突,无法执行该操作。 The files BattleManagerClass.h and BattleManagerClass.m had a tree conflict 文件BattleManagerClass.h和BattleManagerClass.m有树冲突

Following the advice of similar SO questions, I ran git status in the same directory where BattleManager* resides, which returned: 遵循类似SO问题的建议,我在BattleManager *所在的同一目录中运行了git status ,该目录返回:

On branch master.DevMain.14.13.newCombatReports
Untracked files:
    (use "git add <file>..." to include in what will be committed)

        ../CloudKitHelperClass (xxxxxxxx's conflicted copy 2016-11-18).m
        ../yyyyyy.xcodeproj/project.xcworkspace/xcuserdata/thunk.xcuserdatad/.gitignore
        ../yyyyyy.xcodeproj/project.xcworkspace/xcuserdata/thunk.xcuserdatad/UserInterfaceState (xxxxxxxx's conflicted copy 2016-11-18).xcuserstate
        ../yyyyyy.xcodeproj/xcuserdata/thunk.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

nothing added to commit but untracked files present (use "git add" to track)

None of which seem related to the new BattleManager class. 似乎都与新的BattleManager类无关。 After plodding around, not really understanding what I'm doing in GIT, I eventually removed the class from the xcode project and moved the BattleManager files off to ~/tmp. 经过四处摸索,没有真正理解我在GIT中的工作,我最终从xcode项目中删除了该类,并将BattleManager文件移至〜/ tmp。 I committed the change and then successfully merged the rest of the changes in 14.13.NewCombatReports back in to 14.13. 我提交了更改,然后成功地将14.13.NewCombatReports中的其余更改合并回了14.13。 At that point, I re-added the new BattleManager class back into 14.13 and rebuilt. 那时,我将新的BattleManager类重新添加到14.13中并进行了重建。 All was well, or so I thought. 一切都很好,或者我想。

When I subsequently tried to merge 14.13 into 14, I got a TON of tree conflicts, complaining about every single class file I had added in 14.13. 随后,当我尝试将14.13合并为14时,遇到了一堆树冲突,抱怨我在14.13中添加的每个类文件。

So I have apparently done something fundamentally wrong, such that GIT doesn't like it when I try to merge branches upward that contain net new files. 因此,我显然做了一些根本上错误的事情,例如当我尝试向上合并包含净新文件的分支时,GIT不喜欢它。 I don't know the workings of GIT very well and don't understand: 我不太了解GIT的工作原理,也不了解:

  1. What is a "tree conflict" error trying to tell me me in the context of a local repository? 试图在本地存储库中告诉我什么是“树冲突”错误? I don't understand what my current revision is conflicting with. 我不了解我当前的修订版本与之冲突。
  2. how do I fix it so I can merge upwards this branch containing new files? 如何修复它,以便可以向上合并包含新文件的此分支?

This question seems very similar Xcode merge branch,remind tree conflict when add some new file . 这个问题似乎很像Xcode合并分支,添加一些新文件时提醒树冲突 The comments link to: The operation could not be performed because "PROJECTNAME" has one or more tree conflicts which talks about trying to reconcile directory structures between the local and server versions. 注释链接到: 无法执行该操作,因为“ PROJECTNAME”具有一个或多个树冲突 ,该冲突涉及尝试在本地版本和服务器版本之间协调目录结构。 Since I'm not dealing with a server, I don't understand how to apply that advice. 由于我不与服务器打交道,因此我不了解如何应用该建议。

I've seen similar weird failures with xcode attempting git operations. 我已经看到xcode尝试git操作时发生类似的奇怪错误。

Just closing the project, exiting xcode and rebooting has cleared some issues for me. 刚刚关闭项目,退出xcode并重新启动,为我清除了一些问题。

Using one of gui git tools sometimes help, too. 使用gui git工具之一有时也会有所帮助。 There are several different options, but I use gitbox and is available from the app store. 有几种不同的选项,但是我使用gitbox,可以从应用程序商店购买。 It has an option to force a merge, which might solve the problem. 它具有强制合并的选项,这可能会解决问题。

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

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