GitHub does not recognize changes from a reverted pull request

后端 未结 1 1975
花落未央
花落未央 2020-12-29 13:23

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

相关标签:
1条回答
  • 2020-12-29 14:06

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

    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.

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

    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.

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

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

      where COMMIT_HASH introduces the original bug fix.

    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.

    0 讨论(0)
提交回复
热议问题