How to identify a deleted branch

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.


Identify accidentally deleted branches.


Deleted branches can be detected by running the following query in Bitbucket Server:

  • Replace <project_key> and <repository_slug> with the appropriate values:

    select p.project_key, r.slug, pr.ref_id, pr.change_type, pr.from_hash, pr.to_hash,, a.CREATED_TIMESTAMP from sta_repo_push_ref pr join sta_repo_activity ra on ra.activity_id = pr.activity_id join repository r on = ra.repository_id join project p on = r.project_id join sta_activity a on = pr.activity_id join sta_normal_user nu on nu.user_id = a.user_id where p.project_key = '<project_key>' and r.slug = '<repository_slug>' and to_hash like '0000000%' order by a.created_timestamp desc; 
  • The query checks for branches where the tip of the branch is 0000000000000000000000000000000000000000, this identifies a deleted branch.

Once the deleted branches have been identified, if the branch has to be restored, follow the instructions on the How to restore a deleted branch page.

(warning) Note:

Deleting the branch via the UI or the REST API calls will directly apply to the repositories thus there isn't any push reference being recorded in the sta_repo_push_ref table. There is currently an open feature request to add this to audit logging located at  BSERV-7046 - Getting issue details... STATUS

Last modified on Aug 16, 2018

Was this helpful?

Provide feedback about this article
Powered by Confluence and Scroll Viewport.