Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find who deleted a git branch

Tags:

git

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?

like image 857
Pavel Avatar asked Nov 01 '12 14:11

Pavel


People also ask

How do you find out who deleted a Git branch?

Note that if you have access to the remote repo (to which a branch deletion was pushed), you can find trace of the deleted branch in the git reflog . This user is first on the weekly GitLab leaderboard. The reflog for the branch gets deleted when you delete the branch.

Can I see deleted branches in GitHub?

Restoring a deleted branchOn GitHub.com, navigate to the main page of the repository. Under your repository name, click Pull requests. Click Closed to see a list of closed pull requests. In the list of pull requests, click the pull request that's associated with the branch that you want to restore.

Does deleting Git branch delete history?

They remain exactly as they were. If the branch is deleted without being merged into another branch then the commits in that branch (up until the point where the forked from a commit that is still reachable) will cease to be visible.


2 Answers

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.

like image 198
Nic Avatar answered Oct 13 '22 16:10

Nic


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.

like image 4
twalberg Avatar answered Oct 13 '22 17:10

twalberg