Reputation: 1148
I'm using vscode to make a website with HTML, PHP, CSS, JavaScript, etc. and I just lost a lot of my progress.
When I started with this project I init'ed a github repository. I could sync or push, nothing got uploaded to GitHub. But as I was short of time, I continued to program.
As I was playing around with vscode I opened a new branch to see what happened, continued programming on that branch. Today I turned to master again. Just realized that I have lost all my progress.
Is there a way to recover it? It seems that the files are not on my pc, and when I looked into GitHub, again, no repository was created.
I don't know if this is a StackOverflow question, but if nobody knows I will erase it soon, I'm really desperate.
Upvotes: 1
Views: 4415
Reputation: 2645
Run
git reflog
This will output something like this:
f91a6fd HEAD@{0}: checkout: moving from 3 to 4
8588104 HEAD@{1}: checkout: moving from master to 3
1a17da4 HEAD@{2}: checkout: moving from 2 to master
01c34aa HEAD@{3}: checkout: moving from 1 to 2
1a17da4 HEAD@{4}: checkout: moving from d7142f4fc79fe6618381e00802a27e5d79d3566c to master
bb17da4 HEAD@{4}: checkout: moving from login to d7142f4fc79fe6618381e00802a27e5d79d3566c
This is ordered from newest to oldest changes. Let's say you need to change back to "d7142f4fc79fe6618381e00802a27e5d79d3566c". You then run:
git checkout d7142f4fc79fe6618381e00802a27e5d79d3566c
Upvotes: 0
Reputation: 6424
I think that your code is just on another branch.
git checkout [branch]
If your code is on the same branch, but you accidentally deleted the files use:
git reset --hard
This will revert to the state of the previous commit, essentially un-deleting your files.
Upvotes: 1
Reputation: 2675
Go to the folder of your project. Open shell or cmd in that foldeer. Use the command below ro get your files back.
git checkout <old_branch_name>
Or you can simply merge the old branch to master if you have committed it.
git checkout master
git merge <old_branch_name>
Upvotes: 2