Hacker News new | ask | show | jobs
by 29athrowaway 1137 days ago
Jetbrains IDEs have a "Local history" feature that is not well known. It watches local files and keeps a backup of previous versions of a file, independently from version control.

This has saved me from a few accidental unrecoverable changes.

git reflog is also your friend.

1 comments

Iirc VS Code also added that feature last year.

And Vim will also let you go back to any prior state as long as you still have the file open. You can go back to a specific date/time, revert the last 5 minutes etc.

You can enable Vim's persistent undo by setting undofile and undodir options, that way undo works across restarts, no need to keep file open. Another cool feature is Vim's internal undo tree, which allows you to access changes that you undo-ed and then overwrote.