antnewbee
antnewbee

Reputation: 1959

Reverted a pull request from github but both branch shows no difference

I have reverted a pull request from GitHub by following this article https://help.github.com/articles/reverting-a-pull-request/. Now even after reverting when I am comparing the two branch it shows same. How can I raise a pull request again?

Here is what I did

  1. I raised a pull request from prod_bug_fix branch to release/13.0.0 and went to github and merged.
  2. Then I followed the above article and unmerged the pull request. Now I thought release/13.0.0 code would be back as before I raised the pull request.
  3. I tried raising a pull request again from prod_bug_fix to release/13.0.0 but it says "There isn’t anything to compare." . But I can see there are code differences between the two branches.

What I did wrong and how I can make release/13.0.0 to same state as before?

Upvotes: 6

Views: 5333

Answers (3)

ritesh
ritesh

Reputation: 197

Revert will create a new commit that undoes the specified commit. It doesn't remove the specified commit, it just creates a new commit on top of your commit to remove your changes. That's why when you check diff between the branch there will be none because the commit is already present in the branch.

For eg:

Branch A => commit1 => commit2 => commit3

after reverting, commit order will be

Branch A => commit1 => commit2 => commit3 => commit4(this is your revert commit)

Upvotes: 1

David Deutsch
David Deutsch

Reputation: 19035

Since the merge you reverted will always be in the history, you'll need to replay that merge onto prod_bug_fix before submitting your new PR.

First, get prod_bug_fix up to date by checking it out and doing git merge **release/13.0.0** (this will probably be a simple fast forward merge).

Now let's say that the merge you reverted had hash abc123; you would replay all the changes to that merge onto prod_bug_fix with git cherry-pick -m 1 abc123. The -m 1 tells git "replay the changes that were made to the first parent of the merge (release/13.0.0) as opposed to the changes made to the second parent (prod_bug_fix). Once you have done this, a PR from prod_bug_fix to release/13.0.0 will work as expected.

Upvotes: 0

Zoltorn
Zoltorn

Reputation: 171

A little late on this answer, but I encountered this issue myself and finally tracked down that the revert behaves weirdly in that the original commit being reverted is still in the history, so when you go to create a new PR it still thinks it is in there so you see no difference when doing the diff. This StackOverflow answers gives some more details about it.

Upvotes: 2

Related Questions