# Can I enable the "automatically delete head branch" feature on GitHub

**URL:** <https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088>\
**Category:** Core Workflow\
**Created:** [August 6, 2019, 5:20pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088 "2019-08-06T17:20:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mariatta](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mariatta/32/30581_2.png) [@Mariatta](https://discuss.python.org/u/Mariatta)\
**Post date:** [August 6, 2019, 5:20pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/1 "2019-08-06T17:20:25Z")

</div>

Quite recently GitHub added a new feature where head branches can automatically be deleted after the PR has been merged.

Can I enable this in CPython repo? It will save several API calls for miss-islington.  
I don’t see why not, but wanted to check first.

 ![04%20AM](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/8/8f2cf498eb6186fedec452bbeec49f4adf507300.png)

---

<div class="post-metadata">

**Author:** ![pitrou](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pitrou/32/28_2.png) [@pitrou](https://discuss.python.org/u/pitrou)\
**Post date:** [August 6, 2019, 5:33pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/2 "2019-08-06T17:33:48Z")

</div>

I usually do it manually, so I wouldn’t mind. I wonder whether it might take other users by surprise, though.

---

<div class="post-metadata">

**Author:** ![zware](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/zware/32/58_2.png) [@zware](https://discuss.python.org/u/zware)\
**Post date:** [August 6, 2019, 5:44pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/3 "2019-08-06T17:44:45Z")

</div>

Does this apply only to the `python/cpython` repo, or to any fork? Does `miss-islington` create her branches in her own fork, and would setting this there achieve the goal?

Either way, I’m in favor 🙂

---

<div class="post-metadata">

**Author:** ![Mariatta](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mariatta/32/30581_2.png) [@Mariatta](https://discuss.python.org/u/Mariatta)\
**Post date:** [August 6, 2019, 5:55pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/4 "2019-08-06T17:55:00Z")

</div>

Good questions.

> [@zware](#):
>
> Does this apply only to the `python/cpython` repo, or to any fork?

I assumed it works on forks too. But I will make investigate further. [Their changelog](https://github.blog/changelog/2019-07-31-automatically-delete-head-branches-of-pull-requests/) doesn’t say anything about forked repo or not.

> [@zware](#):
>
> Does `miss-islington` create her branches in her own fork, and would setting this there achieve the goal?

miss-islington creates branches in her own fork.

---

<div class="post-metadata">

**Author:** ![zware](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/zware/32/58_2.png) [@zware](https://discuss.python.org/u/zware)\
**Post date:** [August 6, 2019, 6:15pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/5 "2019-08-06T18:15:30Z")

</div>

> [@Mariatta](#):
>
> miss-islington creates branches in her own fork.

In that case, I’d start with enabling it on her fork and see if that does what you want.

For that matter, you could save the API calls anyway, since nobody really looks at what branches are on her fork, as long as she doesn’t run into a limit on the number of allowed forks 🙂

---

<div class="post-metadata">

**Author:** ![Mariatta](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mariatta/32/30581_2.png) [@Mariatta](https://discuss.python.org/u/Mariatta)\
**Post date:** [August 6, 2019, 6:17pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/6 "2019-08-06T18:17:16Z")

</div>

> [@zware](#):
>
> Does this apply only to the `python/cpython` repo,

I’ve just tested in my personal repo, and sadly it won’t delete head branch in forked repo 😔  
. Only if the head branch is created in the same repo`.

Since this won’t help miss-islington’s case, do we still want to enable it in python/cpython?

---

<div class="post-metadata">

**Author:** ![zware](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/zware/32/58_2.png) [@zware](https://discuss.python.org/u/zware)\
**Post date:** [August 6, 2019, 6:19pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/7 "2019-08-06T18:19:29Z")

</div>

> [@Mariatta](#):
>
> Since this won’t help miss-islington’s case, do we still want to enable it in python/cpython?

I’d say yes; anyone making a change via a branch on the main repo doesn’t have to remember to delete it when they’re done.

---

<div class="post-metadata">

**Author:** ![Mariatta](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mariatta/32/30581_2.png) [@Mariatta](https://discuss.python.org/u/Mariatta)\
**Post date:** [August 6, 2019, 6:39pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/8 "2019-08-06T18:39:38Z")

</div>

Done! ✅

---

<div class="post-metadata">

**Author:** ![pradyunsg](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pradyunsg/32/206_2.png) [@pradyunsg](https://discuss.python.org/u/pradyunsg)\
**Post date:** [August 8, 2019, 5:44am UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/9 "2019-08-08T05:44:44Z")

</div>

@Mariatta Does it delete the branch, if it’s checked on both the fork and the python/cpython?

---

<div class="post-metadata">

**Author:** ![Mariatta](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/mariatta/32/30581_2.png) [@Mariatta](https://discuss.python.org/u/Mariatta)\
**Post date:** [August 8, 2019, 5:36pm UTC](https://discuss.python.org/t/can-i-enable-the-automatically-delete-head-branch-feature-on-github/2088/10 "2019-08-08T17:36:54Z")

</div>

I tried that, and no it doesn;t delete the branch that way 😔
