Home > Software design >  Is it possible to recover a deleted branch that you deleted using the Github website?
Is it possible to recover a deleted branch that you deleted using the Github website?

Time:10-19

I accidentally deleted a branch on Github using this tutorial. The gif is mainly what I followed. Is there a way to undo this?

CodePudding user response:

if you ever checked out this branch locally you can use git reflog to get back to it and recreate it.

$ git reflog
434f93d (HEAD -> CMD-28) HEAD@{0}: reset: moving ...
4544567 HEAD@{1}: reset: moving ...
434f93d (HEAD -> CMD-28) HEAD@{2}: rebase (finish): returning ...
434f93d (HEAD -> CMD-28) HEAD@{3}: rebase (pick): WIP x64 DEBUG

note commit id in the left column and do git checkout -b <branchName> <commitId>

Then git push it back to GitHub

  • Related