ottowichterle
ottowichterle

Reputation: 53

How to change a base branch of a closed / merged pull request?

I forked a repository, made some changes, committed them and sent a pull request. The PR was accepted and the changes were merged into the upstream repository. However, I later realized that I made a mistake of issuing a PR from my fork's master branch, instead of creating a separate branch to make all the changes and submitting a PR from there.

I was wondering if there is any way to change the base branch of a closed / merged PR?

Assuming that is not possible, would it be sensible to delete the fork? Though, I am very concerned it would delete all the valuable discussion as well as line comments on the existing PR.

I will be grateful for any help you can provide.

Edit 1: I marked @bk2204 response as an accepted answer since the author further addressed the possible consequences of deleting a fork. Although, @msanford answer was also immensely helpful and I wish I could tick both answers. Cheers!

Upvotes: 5

Views: 1781

Answers (2)

bk2204
bk2204

Reputation: 76409

First of all, it sounds like you're talking about wanting to change the branch associated with the pull request instead of the base branch (the branch into which it is going to be merged). Either way, it isn't possible to change the branch of a merged pull request; the pull request is considered complete, and changing it isn't possible.

It isn't necessary to delete your fork in this case due to using the wrong branch. You can modify your master branch as you wish now that the pull request is closed; the history is archived in the main repository and on the GitHub side, and further changes to your master branch will have no effect on the pull request.

However, if you want to delete your master branch or your fork for other reasons, you can do so without negative consequences to the upstream project or the pull request.

Upvotes: 3

msanford
msanford

Reputation: 12229

Good on you for noticing and wanting to do something about it.

However, the PR was reviewed and merged by someone responsible for the upstream project. That means they accepted your changes, so there's no need to worry about it and nothing for you to do.

To delve more into what you're concerned about, branches are just a useful abstraction for linking together series of commits. The fact that you sent a PR from your own master instead of a patch branch that you branched off master is irrelevant. Assuming you intended to base your patch branch from master, a patch branch and your master end up being the same thing as they contain identical history.

If your patch was going into a feature branch in the upstream repo that did not contain work from master (for whatever reason), the extra changes would have shown up in your PR as well and both you and the upstream reviewer would have noticed.

For completeness: if you did need to fix work that was included by mistake, it would probably take a series of revert commits in a new pull request.

Upvotes: 1

Related Questions