Search code examples
gitgit-branchgerritremote-branch

How to restore the deleted remote gerrit branch


We are using Git & Gerrit, Couple of months back our Ex. Colleague (He was an Gerrit Admin) who had deleted a remote gerrit project branch. Now I have request to restore the deleted remote branch. Locally no one has the copy of that branch. As an Gerrit admin So far I have tired the below ways to restore it, However didn’t worked. Is there any way to restore the same?

Below Commands not showing branch details (or) commit-id

1.  Cloned the project/repository locally.
2.  git reflog  --all 
3.  git reflog --no-abbrev

Below command also not showing my commit-id in .git/lost-found.txt file.

git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d\  -f3 | xargs -n 1 git log -n 1000 --pretty=oneline > .git/lost-found.txt

Solution

  • Through Gerrit Web itself able to restore the branch. (Gerrit Web--> Project--> Branch--> Enter the branch name and input the commit-id/Initial Revision --> Create Branch.