⇦ Back to: Merge Pull Request | ⇧ Overview | ⇨ Next: Update Pull Request
<aside> 💡 Repository owners can set the automatically delete head branches setting in the repository settings. This ensures that pull request branches are automatically deleted (but recoverable) after merging.
</aside>
Once you’ve merged your PR, the branch (a pointer to the last commit before the merge) still exists. You can end up with hundreds or thousands of these “stale” branches with no useful function in a long project, which can make keeping track of the current branches more challenging.
You can delete the branch on GitHub as follows:
Open the branches list from the repository page:
For each branch you want to remove, click on the trashcan symbol:
You can go back to the branch list to recover the branch if deleted in this way:
In the branch list, right click the remote branch and click “delete”.
Click through the warning.
<aside> ⚠️ The branch is then removed on GitHub without the ability to restore it:
</aside>
git
on the command lineTo delete a remote branch, run: