Remote branch unexpectedly git in visual studio

I am working in visual studio 2013 with git and today unexpectedly I deleted a branch. Now when I go to create a branch it doesn't show up in the dropdown to select and create this again.


source to share

2 answers

Step 1:

Create a list of all unreachable commits.

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


Step 2:

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

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


Step 3:

Find the missing commit. Create a new branch with the missing commit as the branch branch.

git checkout -b branch-name SHA




Follow these steps:

  • Do git reflog

    and find the SHA-1 hash of the last commit (i.e. head) of the branch you just deleted.
  • Do git checkout -b <SHA-1>

    where SHA-1

    matches the commit found in step 1.


All Articles