Local History helps us track our local changes for the project, and prevents accidentally loses or modifications of the project, even outside from the IDE. This tutorial will show you how to use Local History to view and revert changes, and how to use labels.
1. Create project from scratch
Create Java project from scratch with name HistoryApp. We will show how to use Local History on example of this project.
2. Create HelloWorldApp class
Create Java class HelloWorldApp. We will try to change this class and see how Local History tracks our changes.
3. Define main method
Now let's define public static main method, which outputs "Hello world!".
4. Show history for file
It seems now we have some changes, so we can check them. Use Local History → Show History action from the context menu in the editor to show the local history of changes for the current file.
Now you see a window with all changes grouped by time. You can select any change and see the difference. You can also revert any changes right here.
5. Add documentation
Add some documentation to our class to finish it off.
6. Put label
Since we have a final version of our class, we may add a label to the history. This label will help us to find a particular version of file in the history.
To add a label use theLocal History → Put Label action from the context menu in the editor.
Specify any name for your label. We will see how it looks in Local History later.
7. Add comment
Now let's make some change we will revert in the future. Add comment to your output statement.
8. Show history for selection
Now let us see all the changes for selected code. Select the output statement and use Local History → Show History for Selection.
Now you see the changes for selected code only. You may easily find the "Initial version" label we added.
9. Revert changes
Let's say we don't need some change and want to revert our code to the previous version. Use Revert action from the context menu on the version you find appropriate.
10. Show history for folder
All actions we used for a class are also available for a folder. Use Local History → Show History action from the context menu on any folder to see the local history of changes.
Now it shows changed files and folders. You can see actual changes for any file.