aleskva aleskva - 5 months ago 42
Git Question

How to recreate a branch from pull request?

I forked a project, created a new branch from master, made changes and created a pull request to the original project. But suddenly I forgot I created this pull request and deleted my fork completely from remote (GitHub) and from my PC as well. How can I recreate a branch (or a fork) from a pull request in order to add a change and let it merge?


There are two things you can do:

1. Contact GitHub support

While trying out my solution for you I deleted a fork where I myself had a PR still pending and had the same situation than you.

There is currently no way to reattach to that PR, besides contacting GitHub support. They can restore the deleted fork which will also reattach it to the pending PR. Then you can simply clone your fork, change your PR branch and push.

It was a matter of minutes in my case until GitHub staff responded to the contact form. applauding to GitHub

2. Make a new PR

If you don't want to bother GitHub support or they are too slow for you or are unwilling, you can do the following:

  • recreate your fork
  • recreate your branch from the pull request by doing git fetch <your configured remote for upstream> refs/pull/<your PR number>/head:<your branchname>

This will recreate the PR branch for you locally, then change whatever you want to change, close the original PR and open a new one.