Accidentally deleted branch, how to restore

Describe your question in as much detail as possible:
Hi, non technical person here!
I have accidentally deleted a branch from my team’s repo and feel absolutely horrible…
Is there a way for a non technical person to recover the branch within the next 4 hours, willing to read and do anything!
This is such a bad feeling, is a branch deleted permanently gone?

Thanks for taking the time to be thorough in your request, it really helps! :blush:

1 Like

Hi,

please don’t create more than one topic of the same question, this won’t speed up replies. I’ve closed the duplicated topic.

In terms of deleted branches, please learn more about reflog and extract the commit SHA1 your branch was on. Then use the checkout command.

git reflog

git checkout -b <branchname> <sha1> 

Cheers,
Michael

3 Likes

You suggest a solution to restore a branch from a local git repository. But the real question is about restoring in gitlab. I miss a similar button like github has to restore a deleted branch. I accidentally merged MR with the delete branch option checked, and now I don’t have a local copy of the deleted branch.

1 Like