Recover deleted branch in Git

This question already has an answer here:

  • Can I recover a branch after its deletion in Git?

    14 answers

  • Remote Git branch authorization
  • Rename master branch for both local and remote Git repositories
  • Git, tell me when a remote branch that I am tracking is removed
  • How to move certain commit to NEW branch
  • delete local branch called “remote”
  • Specify '--remote' Heroku app based on git branch
  • Checking in and out files within branches without moving to the Master Branch
  • Git 'merge' by creating a new checkin based on another branch
  • 2 Solutions collect form web for “Recover deleted branch in Git”

    Create a list of all dangling or unreachable commits.

    git fsck --full --no-reflogs --unreachable --lost-found

    Print a list of commit messages for all commits in the lost and found.

    ls -1 .git/lost-found/commit/ | xargs -n 1 git log -n 1 --pretty=oneline

    Find your missing commit through the process of manual inspection (i.e. reading).
    Create a new branch with the missing commit as the branch head.

    git checkout -b branch-name SHA

    Having got the potential sha1 for the last tip of branch demo, use gitk sha1 to actually browse the commit’s history to check you have the right one.

    Git Baby is a git and github fan, let's start git clone.