I have quite a few changes that I would like to commit to new a branch but I've accidentally been working on the master in VS Code. This wouldn't have been an issue until I have accidentally clicked "Undo Last Commit" (twice, not once) because I almost published to master.
I am now especially worried that my progress will be overwritten when trying to commit my changes because VS Code tells me it would require me to first "pull." (I assume overwriting my files).
Sorry if I am under-informed on my situation, but the thought of losing my progress scares me too much to just start "trying" things as I always do (that's what got me here in the first place).
The answer is really quite simple after looking into what "undo" actually does.
VS Code "Undo Last Commit" simply runs git reset HEAD~
. These actions are in the output if you open up the "GIT" tab. The solution however can be found by looking at what was recorded by running git reflog
and then manually running the git reset
to before VS Code ran it. here is a better reference.
(I'll also leave this up in case someone else has the same worrisome mistake in VS Code)
See below image:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With