Written by: Thiago Nunes Batista
Published on 21/01/2025
Last updated: 21/01/2025
Git is the most widely used version control system in the market. As developers, we usually only scratch the surface of what this tool is capable of. In our daily routine, we typically perform simple actions such as pull, commit, merge, and push.
However, Git is a complex tool, and incorrect usage can result in issues such as losing code that hasn't been committed to your repository yet. If this has happened to you, you were probably very worried that all the time you invested in that code was wasted.
If you use VSCode, one of the most popular code editors among developers, I’m happy to tell you that you haven't lost your code. In this article, I'll show you how to use Visual Studio Code to recover your lost code in Git.
The feature we will use is called "Local History," which was introduced in VSCode version 1.66 in March 2022.
To solve this problem, follow these steps:
VSCode is an amazing text editor, packed with so many features and shortcuts that it’s impossible to know everything it can offer. I was very surprised to discover that VSCode keeps a history of file changes made within the editor. Fortunately, it does, as it can be incredibly helpful when those changes we made but didn’t commit are accidentally undone.