The other day I was happily programming in my cubicle. Overjoyed with excitement that I accomplished my task early, I wanted to quickly check my files into source control. Some files were no longer needed by the application. Using my handy source control tool’s UI, I selected the files (all the changed files) and clicked delete. Uh! Oh! I knew as soon as I hit delete (and the ok button on the “Are you really sure?” dialog) many hours of work were lost. I am no longer a happy programmer.
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.