Is there an expiry time on restoring a deleted branch in a merged PR?

I have a collaborator who is nervous about the longevity of the ‘restore’ functionality of deleted branches in merged PRs.  Can anyone provide some clarity as to how long a merged and deleted PR branch is retained for restoring?

I was under the impression that one can restore a deleted PR branch indefinitely, but I can’t find confirmation of that on the GitHub support pages.  The only information is second-hand, a quote from a GitHub helpdesk reply from 2013 in this StackOverflow answer:

We use a separate ref namespace for all Pull Requests which we use for various things including restoring the branch. Since we keep those [Pull Request] refs indefinitely, there’s no time limit on restoring a branch.

I don’t have a very satisfying answer for you I’m afraid. The branches will be restorable indefinitely, unless the repository cache is cleared.

We don’t clear repository caches automatically (we’re in the version control business, so we don’t delete data unless we absolutely have to :wink:) so usually the only reason we would do that is if we had someone writing in to us asking for us to clear them as part of the sensitive data removal process (Step 8).

It’s also possible we might clear the cache for technical reasons, if the content or structure of the repo was causing us difficulties to host it, but that would usually only happen if the repo was exceptionally large or had a wildly structured folder layout.

Sorry I don’t have a better answer for you!

1 Like

Thanks @that-pat, that’s very helpful indeed.