如果主干的目录结构发生变化,如何将分支合并回主干?

发布于 2024-12-11 17:45:45 字数 373 浏览 0 评论 0原文

历史如下:

  • 从主创建分支。
  • 更改主干上的目录结构。
  • 将新文件添加到分支上的旧目录结构中。

通常的合并方法如下:

  1. 将主干更改合并到分支
  2. 将分支合并回主干

但是,在我的情况下,步骤 1 已经导致树冲突。

我怎样才能最好地完成这项任务?

PS: 可能的重复没有接受的答案。

The history goes as follows:

  • Create branch from main.
  • Change directory structure on trunk.
  • Add new files to the old directory structure on the branch.

The usual approach for merging goes as follows:

  1. Merge trunk changes to branch
  2. Merge branch back to trunk

However, in my situation step 1 will already result in tree conflicts.

How can I best deal with this task?

Ps: Possible duplicate has no accepted answers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别在捏我脸啦 2024-12-18 17:45:45

首先将所有主干更改合并到您的分支中,解决冲突。这很可能与您对主干所做的更改发生冲突,但如果您想合并对不同分支所做的更改,您最终将必须解决这些冲突,而这就是执行此操作的地方。

然后将分支重新整合到主干中。 (请注意,一旦重新集成,该分支就不适合进一步合并。最好的方法是删除它。)


为了减轻过多冲突堆积带来的痛苦,您可以做的一件事是逐步合并更改,而不是而不是一次将它们全部合并。有时,我发现当没有那么多更改时,更容易理解我正在合并的更改。理解这些变化可能是成功合并冲突的最重要方面。

First merge all trunk changes into your branch, resolving conflicts. This will very likely conflict with the changes you have made to the trunk, but if you want to merge those changes made to different branches, you ultimately will have to resolve those conflicts, and this is the place to do that.

Then reintegrate the branch into the trunk. (Note that the branch is not fit for further merges once it's reintegrated. The best is to delete it.)


One thing you can do to lessen the pain of having too many conflicts piling up is to merge changes step-by-step, rather than merging them all at once. I sometimes find it easier to understand the changes I am merging when there aren't so many of them. And understanding the changes might be the most important aspect of successfully merging conflicts.

蓝礼 2024-12-18 17:45:45

您应该定期将主干合并到分支中(当然是在结构更改之后),并在分支完成后使用重新集成选项使主干与分支代码保持同步

you should be merging trunk into branch regularly (certainly after the structure change) and use the reintegrate option to bring trunk up to date with the branch code once the branch is finished with

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文