gitvisual-studio-codegit-branchworkspace

Accidentally deleted local branches after changing the workspace in VS Code


I accidentally lost all local branches after changing the workspace without saving it in VS Code. Now, the only branch I have is master. Is it possible to restore all these lost branches?

Tried to open my previous folder as a workspace, nothing happens


Solution

  • if you have commited your local branches with the help oh git then,

    you can use git reflog command.

    the output will show you the commit hashes.

    if you find the lost commit in the reflog, you can reset you branch using that hash.

    for that, use git reset --hard <commit_hash> ( 'commit_hash' -- actual hash you found in the reflog)