Automatically Delete Branches after Merging Pull Requests on GitHub

Joe Previte
InstructorJoe Previte
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 2 years ago

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.

egghead
egghead
~ 49 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today