Reputation: 820
I accidentally discarded 2 uncommited files from my project. Is there any way to undo these changes/bring those files back. I use IntelliJ and VS Code simultaneously. MAybe some kind of editor cache or history where I can view last hour or so changes and copy those??
Upvotes: 9
Views: 8197
Reputation: 820
I found the answer. There seems to be no way to do this using just GIT. But an Editor like IntelliJ really helps. IntelliJ maintains a local history of changes you did (even uncommitted) and you can revert to any point in time (caveat it keeps history only upto few Days).
IntelliJ Project tab -> rt click there -> select Local History -> Show History. Just select the point in time you want to go and revert.
This Post will also be helpful for detailed steps https://blog.jetbrains.com/idea/2008/01/using-local-history-to-restore-deleted-files/
Upvotes: 20
Reputation: 41281
If you created the file using IntelliJ, you're in luck since IntelliJ will track local history of edits and allows restoration. Right click the project in the project view, and select Local History. You'll be able to find the step in which the file was deleted, and will be able to roll it back with a right-click.
Upvotes: 4