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
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>| | |
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!
Hey everyone, over the past year, we've added several new features on how you can use Bitbucket and Jira together. We'd love to know how you'll are using the integration and how it's helping your t...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events