Traveling Back In Time With IDEA
by Brian M. Coyner
But wait... I am using IDEA, which I know can help me. IDEA has a great feature called Local History. As you code, run, debug, etc. IDEA is tracking and labeling your code. At any time you can ask IDEA to show you the local history of a file. The local history displays a colorful side-by-side comparison of the file. Simply find the code you want, copy-n-paste, and you are back in business. In the case of a deleted file, simply show the local history for the directory where the file lived. IDEA then allows you to restore the file. Really cool!
Brian Coyner's Rules of Thumb:
- Always "sit on your hands" before executing a command to delete something.
- Use an IDE that supports local history in case you forget to sit on your hands.
Also use command line interface
I use the command line interface to interact with a Subversion repository. The same would apply to any other SCM tool with a CLI. For instance, I prefer the Perforce CLI to the GUI so as to avoid the kind of problem you encountered. The CLI encourages more attention to local modifications and to the subsequent commit than a GUI. In the case you illustrate, I would have deleted the files one by one as soon as I made the decision to delete them: