- List where your branches have been
git reflogEach line starts with a short commit ID. Find the line from just before things went wrong. Press q to leave the list.
- Bring that commit back on a new branch
git switch -c recovered-work a1b2c3dThis is the safe way: it makes a new branch and leaves everything else alone.
Check it worked
- Check your work is back
git log --oneline -5The commit you wanted should be at the top.
- List where your branches have been
git reflogEach line starts with a short commit ID. Find the line from just before things went wrong. Press q to leave the list.
- Bring that commit back on a new branch
git switch -c recovered-work a1b2c3dThis is the safe way: it makes a new branch and leaves everything else alone.
Check it worked
- Check your work is back
git log --oneline -5The commit you wanted should be at the top.
- List where your branches have been
git reflogEach line starts with a short commit ID. Find the line from just before things went wrong. Press q to leave the list.
- Bring that commit back on a new branch
git switch -c recovered-work a1b2c3dThis is the safe way: it makes a new branch and leaves everything else alone.
Check it worked
- Check your work is back
git log --oneline -5The commit you wanted should be at the top.

New to branch? I explain it in plain English on Layman Terms.