0

I was working on a file then deleted it by mistake before commiting. I restored it but I don't see any changes, was restored to the initial version. Is there a way to see what I was working on?

Muhammad Zahab
  • 1,049
  • 10
  • 21

2 Answers2

0

Depends on your IDE. If you are using Jetbrains look for Local History in the File menu and see if it has stored those changes.

Edit - To avoid this in future consider using one of the two following plugins:

https://marketplace.visualstudio.com/items?itemName=micnil.vscode-checkpoints

https://marketplace.visualstudio.com/items?itemName=xyz.local-history

Be aware that this can cause VS Code to get confused, please see the following answer for more details: How to see local history changes in Visual Studio Code?

Zach Tait
  • 160
  • 8
0

I deleted a file but didn’t commit

$ git checkout HEAD "filename"

I deleted a file and committed the deletion

$ git reset --hard HEAD~1

I committed the deletion and then I did more commits

$ git log -- <filename>
$ git checkout <commit hash> -- <filename>
$ git checkout <deletion commit hash>~1 -- <filename>

I deleted a file, committed and pushed

$ git revert --no-commit <commit>

Here is the reference.

Muhammad Zahab
  • 1,049
  • 10
  • 21