Delete Head Branch (Deprecated)
Delete pull request head branch. Deprecated in favor of GitHub's built-in "Automatically delete head branches" setting.
The delete_head_branch action allows Mergify to automatically delete the head
branch of a pull request once it has been merged. This can be useful for
maintaining a clean repository and reducing clutter from unused branches.
Parameters
Section titled Parametersforce#If set to true, the branch will be deleted even if another pull request depends on the head branch. GitHub will therefore close the dependent pull requests.
Branches Mergify Refuses to Delete
Section titled Branches Mergify Refuses to DeleteMergify does nothing on a pull request coming from a fork, since the head branch
is not yours to delete. Unless force is set, it also refuses to delete a
branch that other pull requests still use, and GitHub refuses to delete a
protected branch or the repository’s default branch.
The author of a pull request picks its head branch, so a rule whose
conditions describe only the state of a pull
request deletes whichever branch that person named as the head. That leaves
long-lived unprotected branches exposed, such as a staging or a release branch.
A condition on the author or on a
label, or a pattern on head, keeps the rule off them.
Examples
Section titled ExamplesHere is an example of how the delete_head_branch action can be used in your
workflow:
pull_request_rules: - name: delete head branch after merge if the label "cleanup" is present conditions: - merged - label = cleanup actions: delete_head_branch:In this example, Mergify will automatically delete the head branch of a pull request once it has been merged, but only if the pull request has been labeled with “cleanup”.
Was this page helpful?
Thanks for your feedback!