Reputation: 166
Someone has deleted a remote git branch (I had not a local copy of it). Is it possible to find who and when deleted the branch?
Upvotes: 14
Views: 5129
Reputation: 456
I know this is old, but maybe someone will find it useful If your git server is Bitbucket server and you have access to the DB, you can run the following query:
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%' and ref_id='refs/heads/<branch_name>' order by a.created_timestamp desc;
Make sure to replace the project key and repository and branch name. After execute you will find user name in the name column
Upvotes: 1
Reputation: 62369
In general, no, unless you have utilized the various hooks to do some sort of logging, or configured git-daemon
to log connections, or if you use ssh
connections, your syslog
configuration might have captured enough information to correlate with.
Upvotes: 5
Reputation: 13733
If you have access to the remote repository (and it was done recently), you can use reflog
to find out when the branch was deleted. You can then create a branch on that commit to recover it if needed.
The gitolite documentation gives some more information.
Upvotes: 6