gitgithubvisual-studio-codefile-recovery

How can I recover git files from computer? Everything deleted from computer after creating new branch


I have a repository for Task-App

The main branch was with the Vite packges of the project I created first.

Then I decided to change all the project and recreate but with Nextjs packege instead, so I deleted all files in 'in my computer' and created a new one (reusing somethings from the old one).

At this point the old project was in GitHub and the new one in my computer.

So when I was going to commit, I selected the option to create a new branch (in the GitHub app) and all my new files was deleted and the old ones placed.

See the repository here: https://github.com/HigorR456/Task-App My VSCode is still opened and the new files I created in my computer was red with the letter D (meaning it were deleted).

How can I recover the files and delete these old ones?

I still didn't do anything, I just commited and published the new branch hoping to get the new files back but not. I expect to recover the files.


Solution

  • I managed to solve this problem, when I selected the option to create a new branch, GitHub created a clone from the latest commit (several days ago) and pushed all files into my computer, but the files I had edited and not commited yet were still there but in the main branch waiting for my response, whether I would like to restore or discard those changes. So when I selected the option restore, it replaced the old files and I got everything I had edited through those days back.

    As you can see there is the main branch and the nextjs branch I had created, the nextjs branch is a clone from the old repository commited several days ago and the main branch was restored to the files I've been editing since them and I just commited to avoid losing everything