How to restore a deleted branch that is associated with a Pull Request in your repo – 024

Suppose you want to restore a branch that’s been deleted after you merged a Pull Request. (TBH: I’m not sure under what conditions you want to restore a branch that’s been merged. If you need to make more changes, my guess would be to create a new branch and a new Pull Request. I’m curious to hear other’s thoughts in the comments.)

But when you go to your list of branches by clicking the Branches link above the repository language bar

branches link above repository bar

You’ll find that your recently deleted branch (e.g. readme-draft) isn’t listed.

list of all branches

Since the readme-draft branch you saw me delete from the previous tips is tied to a Pull Request, you can navigate back to that Pull Request (make sure you search for closed Pull Requests!!)

searching for closed pull requests

and now you’ll see the button to restore the deleted branch.

Restore the delete branch button on closed pull request

Clicking on Restore branch button takes you right back to where you were at in the Pull Request before you deleted the branch, with the exception of history that you’ve restored the branch.

image

You’ll also see the branch come back in the Branch:master dropdown switch button.

Branch dropdown switch button showing readme-draft again

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s