0

I found a bug in a merged PR and am about to revert it.
In the same repo, there is currently another open PR that can't be merged quite yet.

I want to push the changes for the bug fix to one of the PRs.. How do I specify which PR to push to?

I have been on the same master branch instead of using separate branches.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
wangg131
  • 51
  • 4

2 Answers2

1

Well, since the broken change was already merged in and published, then in 99% you can do nothing with that¹.

To fix the situation you should create another commit, and then create another (third) PR clearly explaining in its commit message that the commit is a revert of a given previously merged commit/PR. Then you and the repo maintainer are to go the usual way of merging PRs, possibly including merges with other open PRs

To revert a change git has a designated tool.

¹ - technically git also has a method to amend broken commits (git commit --amend) and other advanced ways to fix previously made mistakes. But all those methods are to change commit sequence which is not that convenient for other possible repository users (they need to rebase their changes against the fixed commits). That's why amending is rarely used for published commits in public repositories. But certainly you could use amending and branch rewriting for unpublished commits in your local repo or when all of repository users are aware of your "hackerish" actions.

user3159253
  • 16,836
  • 3
  • 30
  • 56
  • I'm sorry.. what does "published" mean in this context? Does that mean that it has been published because it has been merged to master? – wangg131 Dec 16 '15 at 19:00
  • Yes, "published" — this commit has become available to a unspecified number of parties. Technically, there're many ways to publish a commit, but this particular one has been published through a PR on github. Therefore it's too late to amend it, you should create another commit which fixes a discovered problem – user3159253 Dec 16 '15 at 22:59
0

I want to push the changes for the bug fix to one of the PRs.. How do I specify which PR to push to?

That's a bit odd question. You mentioned two PRs. One of them is merged. A "merged PR" is not a PR anymore. Maybe you really meant: How do I specify which branch to push to? A "merged PR" is nonsense, but you can of course push the source branch of the PR.

You can specify a target branch as usual:

git push origin localbranch:targetbranch

After this, you'll have to create a new PR from targetbranch, since the old PR is gone.


I found a bug in a merged PR and am about to revert it.

Let's say that the PR was merged into master.

Here's a clean way to fix the bug:

  1. Create a new branch from master, and apply your bugfix on it.

  2. Create a new PR into master

No need to overcomplicate this.


I have been on the same master branch instead of using separate branches.

If you want to use this local master branch of yours, then rebase on top of the remote master.

janos
  • 120,954
  • 29
  • 226
  • 236
  • Thanks for your tips. I'm new to coding and still getting the hang of git. I'm still in the process of learning, and of course I don't want to overcomplicate things.. I want this to be resolved in the cleanest way possible. I just didn't know how, which is why I'm asking in the first place – wangg131 Dec 16 '15 at 22:44