GitHub无法识别回复的拉取请求中的更改 [英] GitHub does not recognize changes from a reverted pull request

查看:95
本文介绍了GitHub无法识别回复的拉取请求中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个名为bug-fix-1的Git分支上,该分支是基于integration分支创建的.还有另一个分支bug-fix-2合并到integration分支中,然后我们还原了更改(所有更改均在Github上完成).

I'm working on a Git branch called bug-fix-1, which I created based off integration branch. There was another branch bug-fix-2 which was merged into integration branch and then we reverted the changes (all were done on Github).

现在,当我提出一个新的拉取请求以将我的bug-fix-1合并到integration中时,我希望看到从bug-fix-2中拉出的更改.但是不,我看不到它们,拉取请求仅显示我在bug-fix-1上所做的更改.

Now when I put up a new pull request to merge my bug-fix-1 into integration, I expect to see the changes which I pulled from bug-fix-2. But no, I can't see any of them, the pull request only show the changes I made on bug-fix-1.

关于如何将bug-fix-2中的更改引入我的分支并将它们合并到integration中的任何解决方案?

Any solution on how do I pull in the changes from bug-fix-2 into my branch and merge them together to integration ?

推荐答案

这是Git的一项有趣功能,一旦意识到正在发生的事情,这并不是一件坏事.

This is an interesting feature of Git, and not such a bad one once you realize what is happening.

Git通过提交哈希跟踪提交,并且历史记录hot-fix-2已经存在. Git还知道已经应用了还原,但是它并没有真正将其还原为原始提交.相反,它只是另一次提交,它恰好反向应用相同的diff,并且它也具有自己的提交哈希.

Git tracks commits by commit hash, and from the history hot-fix-2 is already present. Git also knows that the reversion has been applied, but it doesn't really see it as backing out the original commit. Instead, it's just another commit that happens to apply the same diff in reverse, and it has it's own commit hash too.

为了使Git能够看到更改,您可以选择以下一种:

In order to allow Git to see the changes, you have one of several choices:

  1. 还原还原.听起来很奇怪,但它确实有效.这就是说要引入一个包含反向差异的新提交.该提交不在集成分支上,因此Git会将其视为要引入的更改.

  1. Revert the revert. As weird as it sounds, it works. This says to introduce a new commit that contains the reverse diff. That commit is not present on the integration branch, and so Git will see it as a change to be brought in.

您可以选择原始提交,但需要特殊选择:

You can cherry pick the original commit, but you'll need a special option:

git cherry-pick --keep-redundant-commits COMMIT_HASH

其中COMMIT_HASH引入了原始的错误修复程序.

where COMMIT_HASH introduces the original bug fix.

还有其他方法可以帮助实现此目的,但是它们有些复杂,涉及使用git rebase.我认为上述技术可能是最简单的方法.

There are other ways to help do this too, but they're a bit more complicated and involve using git rebase. I think the above techniques are probably the most straight-forward.

这篇关于GitHub无法识别回复的拉取请求中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆