首页 > 解决方案 > 如何获取先前合并到主分支的整个更改列表?

问题描述

我有一个工作分支 WB,我使用 PR 合并到 master。然后我恢复了master中的这些更改。

现在,如果我创建一个新的 PR(WB 到 master),我看不到整个更改列表,只有最后一次提交的最后一次更改,以及完整的提交列表。

如何查看整个更改列表?

谢谢

标签: git

解决方案


你的情况:

     WB got merged here (through PR)
             |  got reverted here (through another PR maybe ?)
             |     |
             v     v
*--*---*-----M--*--R--* <- master
    \       /
     *--*--* <- WB

正如您在上图中所见,git现在认为WB,在其当前状态下,已经合并master

您需要选择一种方法来创建可以带回您想要的更改的内容:

*--*---*-----M--*--R--* <- master
    \       /          \
     *--*--* <- WB      *--* <- newWB (with changes)

创建此newWB分支的一种方法是“revert the revert”:

  • 如果还原是在一次提交中完成的:
# create a new branch starting off master :
git checkout -b newWB master

# re-revert the 'R' commit :
git revert R
# create a new branch starting off master :
git checkout -b newWB master

# revert the merge commit :
git revert -m 1 R

您现在可以推送该新分支并将其合并到master.


推荐阅读