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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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

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 !

0 votes
Ana Retamal Atlassian Team Dec 05, 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

my question is for Bitbucket server

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,926 views 0 7
Read article

Community Events

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

Events near you