Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

is it possible to know who deleted the feature branch and when was it deleted?

Chaitali Chanda
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 29, 2018

I want to know if we can have a record of who deleted the feature branch from Bitbucket and how to keep a record of who had deleted the branch

2 answers

1 vote
Mohit Garg
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 23, 2019

Hi,

Yes it is possible to know who deleted a branch in Bitbucket server but you need access to Database. Whenever a branch is deleted the hash moves from a revision number to series of 000000000 and you can check the same using following commands after connecting to DB:

A) select * from sta_repo_push_ref | grep <branch_name>;

and look for something like below where first column is activity id and third column value is '2' which means branch deletion:

20034 | refs/heads/feature_<branch_name> | 2 | 1e624235uhjdhhghlb6200cdbc86a4458fc1dfbf5 | 0000000000000000000000000000000000000000

B) select * from sta_activity where id = 20034; which will give you user_id in last column:

20034| 6 | 2019-09-09 18:24:24.864 | 34

C) Finally select * from sta_normal_user where user_id = 34; and here is your culprit.

user_id | name | slug | locale | deleted_timestamp | time_zone
---------+----------------+----------------+--------+-------------------+-----------
34| <Culprit_Name> | <Culprit_Name>| | |

Cheers!!

SanthoshSubramanian May 11, 2020

Hi, Can you share the steps how we can access the Bitbucket database.

Thanks !

0 votes
Ana Retamal
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 5, 2018

Hi Chaitali, welcome to the Community :)  

You didn't mention if you're using Bitbucket Server or Cloud, and also this is mor of a Gt question rather than a BItbucket question, but anyway, let's get at it.

By default Bitbucket Server will not log branch updates or deletes. You can turn on more verbose logging by adjusting the appropriate config property, the list of audit events and levels are here. This other article can also be interesting How to identify a deleted branch in Bitbucket Server.

Bitbucket Cloud doesn't log branch deletion, so you'll need to use your git skills to retrieve that info.

In both cases you can try git reflog. It will tell you who/when it was done so you can get a clue. You can read more about it at Git reflog and the official documentation for Git. For the future, you could also setup a hook which will prevent users from deleting important branches with this add-on from the Marketplace (only for Server).

If you're looking to recover the branch, you can find some tips at How to restore a deleted branch and  http://stackoverflow.com/questions/16793637/recover-deleted-branch-git.

Hope that helps!

Ana

Chaitali Chanda
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 6, 2018

my question is for Bitbucket server

Alen Hodzic
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 24, 2024

For someone who stumbles upon this answer, you can find it in Repository settings-> Push log and choose a branch. There should be an action for that branch: "DELETE BRANCH"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events