In the settings of your repository, in the Merge Button
section, select Automatically Delete Head Branches
. Now when you merge a branch, the branch that is being merged will automatically be deleted.
If you prefer to learn by reading, you can read the accompanying blog post.
Joe Previte: [00:00] From the GitHub repo page, head over to Settings. Scroll down until you see the Merge button section here. You'll see we have a box right here, Automatically delete head branches. Let's check that.
[00:17] Now let's see it in action. We'll merge these pull requests, and you'll notice there is no prompt asking if we want to delete the branch. Let's verify that it's been deleted for us.
[00:26] Heading back over to the main page, we'll click on branch and you will see that now we only have the master branch. That's because with this setting enabled, all head branches will be deleted after they're merged in through a pull request. That's it.