How to identify a deleted branch

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: サーバーと Data Center のみ。この記事は、サーバーおよび Data Center プラットフォームのアトラシアン製品にのみ適用されます。

目的

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, nu.name, 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 r.id = ra.repository_id 
    	join project p on p.id = r.project_id 
    	join sta_activity a on a.id = 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.

The <project_key> is the key defined for the project in the project table, and the <repository_slug> is the repo slug defined in the repository table.

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.


Bitbucket versions earlier than 7.20 do not log branch create and delete events performed through the UI in the audit logs.
This has been addressed from version 7.20 onwards, as part of the feature request,  BSERV-7046 - Getting issue details... STATUS

最終更新日 2022 年 4 月 6 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.