Can I recover staged changes after checkout?

767 Views Asked by At

Recently, I staged many changes in over 100 files. Then, unfortunately, I did a checkout of a previous commit. After the checkout all my changes are gone and not visible anymore (I'm using Fork to work with git). Are my changes really lost or can I recover the changes anyhow?

Please help!

1

There are 1 best solutions below

2
On

I was working in VSCode and staged all changes (using the GitLens extension).
Next I double clicked on a commit and this commit was checked out (no message or warning).

The previously staged changes are not shown anymore

That last part needs to be verified in command-line, outside of VSCode.

git status
git stash list

If not, as commented by Philippe, git fsck can somewhat help.

But check first what extension you are using: a double-click on a commit history should not switch to it directly, unless your VSCode+Git Lens also uses the Git Graph extension.
That extension includes issue 39: "On double click - Checkout branch", which seems close to what you have experienced.