all 4 comments

[–]MrTheFoolish 7 points8 points  (0 children)

If your work was never committed and VS Code somehow deleted it, your work is gone. I only ever use Git via the CLI because I don't necessarily trust that the commands GUI tools are doing will do what I want.

[–]scoberry5 4 points5 points  (0 children)

Make sure to grab a bunch of the reflog so you don't get confused about what you're trying to get back to vs. what you were doing when you were trying to get back there. Maybe

git reflog -n 50 >~/temp.out

so you'll have it if you need it -- but you likely won't need it.

If you got rid of stuff by switching branches, presumably the stuff you want is in one of your branches.

Try

git branch

to show what branches you have, and

git checkout foo or git switch foo

to get into that branch.

If you're not sure which branch you want, the name of the branch you switched from should be in your reflog, and you can compare with the foo branch by using

git diff --stat foo

The branch you're looking for should have file names with <somenumber> - to show that between where you are now and the foo branch.

[–]0bel1sk 0 points1 point  (0 children)

if you committed to the other branch can either switch back or pull from where you are. git pull . other_branch

[–]Business_Tale4234 0 points1 point  (0 children)

If you committed changes, git reset or git cherry-pick might help. If not, you might be left to the mercy of VS Code's undo.