git lens supercharged extension vscode, how to roll back to previous commit in branch main

61 views Asked by At

enter image description here

This was the last commit I did from the branch main, I did right click, it's showing me my options, maybe I can retrieve it, but I don' know which option to click for that.

The major mistake I did was that I committed but did not synced. So it's not showing in my local repo.

This is what happened to me:

I completed my project, I was using gitlens supercharged extension, and I was doing everything in branch main.

Then in my vscode, bottom left I pressed "main" to change it to master, then I pressed "master". Then it gave me 4 options. Then I guess I pressed the second or third option.

Then all my files got deleted.

Basically the files initially uploaded to master, came back to me.

I am thinking my code will merge to master, but master code got merged here.

So is there any way I can retrieve my files back?

1

There are 1 answers

0
Jaredo Mills On

Yes, you can get the files back.

Find the "reflog" which is a log of the last operations you've done. You can reset your main to whichever previous version was good.

With git there is no need to panic. Instead, treat each scare as a learning opportunity, and go read some beginner introductory tutorials which teach the elementary concepts of git.