【问题标题】:Git: how can i merge two branches by resolving merge conflicts on the tip nodes only?Git:如何通过仅解决尖端节点上的合并冲突来合并两个分支?
【发布时间】:2013-08-23 01:07:51
【问题描述】:

这是我的树,有两个分支:狗和猫。

A - B - C - D <- dog
|
E - F - G - H - I - J - K - L <- cat

每个字母都是一个提交。我正在研究分支猫,需要从分支狗获取所有更新的更改。

我正在执行的命令是:

git checkout cat
git rebase dog

我现在正在解决合并冲突,但它似乎要求我通过合并 A & L、B & L、C & L 和 D & L 来解决合并冲突。我只想解决这些冲突用于合并 D & L,因为 A、B 和 C 中的所有内容都已反映在 D 中。有没有办法做到这一点?

【问题讨论】:

  • 如果要合并,为什么要rebase?

标签: git merge branch git-merge rebase


【解决方案1】:

变基基本上会撤消您的所有更改 (E-L),将您的代码更新为 D,然后在 D 之上进行所有更改 (E-L)。这并不是您真正想要的。

我认为你应该做一个 git 合并。

git checkout cat
git merge dog

来自 git-merge 手册页:

包含来自命名提交的更改(因为它们的历史与当前不同 分支)到当前分支。 git pull 使用此命令来合并来自另一个的更改 存储库,并且可以手动将更改从一个分支合并到另一个分支。

   Assume the following history exists and the current branch is "master":

                 A---B---C topic
                /
           D---E---F---G master

   Then "git merge topic" will replay the changes made on the topic branch since it diverged from master
   (i.e., E) until its current commit (C) on top of master, and record the result in a new commit along
   with the names of the two parent commits and a log message from the user describing the changes.

                 A---B---C topic
                /         \
           D---E---F---G---H master

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-15
    • 2021-04-02
    • 1970-01-01
    • 2018-04-19
    • 2020-06-15
    • 1970-01-01
    • 2018-08-04
    相关资源
    最近更新 更多