繁体   English   中英

如何从合并和还原的PR到新的PR中获得提交?

[英]How do I get commits from a merged and reverted PR into a new one?

简而言之,我处于以下情况:

创建了一个功能分支,工作了一段时间,收集了大约30个提交,然后合并到master 然后通过GitHub的Web界面还原合并(通过创建一个新的PR来还原旧的PR的效果)。

现在,我已经解决了导致我们还原合并的问题,并且我想创建一个新PR,同时包含原始PR中的所有30个左右的提交以及我的修复。

我已经将我的feature-fix分支建立在feature分支的(未合并)头上,再次提交了几次,然后推动创建PR-但由于某种原因,PR只选择了新提交,而不是旧的。

如何在新的PR中包含旧提交?

我不得不回购推送权限(我们使用的是共享的回购模式 )等几乎不需要力,推到任何操作master都OK。

简化的git历史记录:

* [feature-fix]  <-- This is the branch I want to pull from now
| * [master]
| * [merge revert PR]
* |\
| | * [revert PR]
* |/              <-- This is the first commit included in the new PR by github
| * [merge PR]
|/|
* | [feature]  <-- This is where the original PR came from
| |
* |   <-- I want these commits, originally included in the old PR, to be included
* |       in my new PR too.
| |
* | <-- Started work on feature here. This is the first commit I want to include.
 \|
  * <-- Common ancestor between `feature-fix` and `master`, as far as I can see

如果我对您的理解正确,则需要执行以下操作。

git checkout master
git revert SHA_OF_MERGE_REVERT_PR
git merge feature-fix 

关键步骤是还原已还原合并的提交。 该SHA删除了所有更改,但保留了所有合并历史记录,这就是为什么您仅看到新的提交的原因。

您可以在此处从Linus自己那里了解更多信息

暂无
暂无

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

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