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
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!!
Hi, Can you share the steps how we can access the Bitbucket database.
Thanks !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
my question is for Bitbucket server
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much @Alen Hodzic This is exactly what I was looking for as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.