0

我正在尝试重新组织 GIT 存储库,其中充满了无组织的分支。现在我们想在那里建立一些结构(开发、生产、功能、......分支)并删除/压缩许多小的更改。但是需要一些东西来保持现状,因为有人在努力。

所以我创建了大结构,把旧的东西压在一起(不再对多年前的小错字修复感兴趣),并在今年开始基本上修复了所有东西。

但是现在问题来了 - 一些分支是活动的,不能被完全压扁,不能被删除/移动(直到新模式证明可以工作一段时间)并且内部包含很多小的合并,如下所示:

  jacks_branch   
    A-B-C-F-G-H-I-J-M-N-O-P ...
            \D-E/    \K-L/

我想将其复制到适当的功能分支之上,例如

  feature_123
    XX-YY
  =>
    XX-YY-C'-F'-G'-H'-I'-J'-M'-N'-O'-P' ...
                \D'-E'/     \K'-L'/

(架构更复杂,这是有问题的部分)

我想做类似的事情

git checkout feature_123
git cherry-pick C..P

但它会导致所有这些合并发生冲突

error: could not apply E
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

提交(合并)解决了I所有这些冲突,但它没有被应用并且樱桃采摘停止

最好的出路是什么(除了从一开始就组织好)?


编辑 - 添加示例:

我有

* 3b0a2b4 3.line Adam (HEAD, Adam)
*   c04efb0 Just fixed merge from other computer
|\
| * 3e5f111 2.line Adam_a
* | 897bfc3 2.line Adam_b
|/
* 308a3c5 1.line Adam
* 33f3119 === new year ==== (master)
* 436619b 1000.line
.............
* 0a12c01 4.line
* 41d763d 3.line
* dd1feb0 2.line
* 55aa2c2 1.line
* 84b12e9 Point zero

请看,分支Adam中存在冲突(3e5f111 和 897bfc3 分别添加行Adam_aAdam_b到同一个地方),开发人员 Adam 在 c04efb0 中以某种方式解决了这个问题(通过在那里写一些完全不同的东西,比如Adam_* # it does not matter左右)

我想添加新的分支develop- 这很容易master

* 75675e1 === new_year === squashed 1.000 lines (HEAD, develop)
* 84b12e9 Point zero

现在我想添加带有内容的分支feature_1(over ) (但不必手动解决所有已经解决的冲突,我希望合并(4444567)与分支相同)developAdamAdam

* 555567 3.line Adam (HEAD, feature_1)
*   4444567 Just fixed merge from other computer
|\
| * 3334567 2.line Adam_a
* | 2234567 2.line Adam_b
|/
* 1234567 1.line Adam
* 75675e1 === new_year === squashed 1.000 lines (develop)
* 84b12e9 Point zero

得到这个:

* 555567 3.line Adam (HEAD, feature_1)
*   4444567 Just fixed merge from other computer
|\
| * 3334567 2.line Adam_a
* | 2234567 2.line Adam_b
|/
* 1234567 1.line Adam
* 75675e1 === new_year === squashed 1.000 lines (develop)
| * 3b0a2b4 3.line Adam (Adam)
| *   c04efb0 Just fixed merge from other computer
| |\
| | * 3e5f111 2.line Adam_a (Adam_a)
| * | 897bfc3 2.line Adam
| |/
| * 308a3c5 1.line Adam
| * 33f3119 === new year ==== (master)
| * 436619b 1000.line
| * 0a12c01 4.line
| * 41d763d 3.line
| * dd1feb0 2.line
| * 55aa2c2 1.line
|/
* 84b12e9 Point zero

(稍后我将删除Adamand master

4

1 回答 1

1

我认为你(和你的团队)现在应该专注于使用你想要使用的工作流程,而不是试图重写历史。这让我想到了下一点,如果继续使用特定的 git 工作流程,而团队中的其他成员继续使用你当前的工作流程,你可能不会成功。

假设您的存储库中的各个分支没有太大的分歧,您和您的团队应该开始合并和整合您希望您的存储库看起来像的任何东西,例如主分支和功能分支。

重写历史记录(例如使用变基)是很棘手的,因为这意味着自从您正在修改或压缩的那个提交之后的每个提交也必须被重写,这意味着您的这些提交的新版本不再匹配其他所有人的“旧”版本。在最近的历史中谨慎使用时,它可能很有用,但重写整个存储库的历史并期望与积极的开发相协调并不是我曾经尝试过的事情。

于 2016-03-08T21:36:47.780 回答