Local History helps you constantly track all changes made to project files and its structure, independently of version control. Unlike version control systems that show the differences between specific commits, Local History automatically maintains revisions for all meaningful changes, both made from the IDE and external changes. This produces a detailed timeline of changes in project structure and source code with the ability to roll back to any point if necessary.
View Local History
View Local History for a file
Find the file that you want to study and open it in the editor.
Selectfrom the main menu or right-click anywhere in the file and choose .
This will bring up a dialog with the list of changes to the file in the left and a diff viewer for the selected change on the right.
View Local History for a project node
Select a project node in the Project tool window.
Selectfrom the main menu or right-click the node and choose .
This will bring up a dialog with the list of changes to the selected node in the left and a list of changed, removed, or added files on the right. To study changes in a specific file, select it and press Ctrl+D or right-click it and choose Show Difference.
In some cases, you may not want to view Local History for the whole file, but only for specific source code elements: classes, their members (fields and methods), or the selected fragment of text.
View Local History for a class, field, or method
Right-click the name of a class, field, or method in the editor and selectfrom the context menu.
View Local History for a source code fragment
Select a code fragment that you want to study.
Right-click the selection and choosefrom the context menu.
There is another global entry point for the local history that allows you to quicklly list local changes from the entire project.
View recent changes
Selectfrom the main menu.
In the popup that opens, select a change to view the list of files added, removed, or modifed in this change.
Revert your code to a specific state from the history
Select a revision in the left part of the Local History dialog.
Do one of the following:
To revert the whole file or directory to the state of this revision, right-click it and choose Revert from the context menu or click on the toolbar.
To revert specific changes in a file, switch the diff view to the Side-by-side-viewer using the selector on the toolbar, and then click next to the desired changes.
This adds a new revision to the Local History.
Add labels to specific states Local History
Local History revisions are normally marked with timestamps, which are not easy to navigate. Some revisions are automatically marked with labels based on predefined events: running tests, deploying apps, committing changes, etc. You can always add a new label to mark the current state of the Local History, for example right before you start a massive refactoring.
Selectfrom the main menu.
In the dialog that opens, type any meaningful name for the label and click OK.
Share Local History
Local History does not support shared access, it is stored locally and intended only for personal use. However, you can create a patch file with changes relative to a specific revision, which you can share with others.
Select a revision in Local History dialog and click Create Patch on the toolbar.
In the dialog that opens, specify how you want to create the new patch.
Retention period for Local History
By default, Local History is configured to store revisions for the last 5 working days (that is, days when the file was modified).
Change the retention period of Local History
Press Ctrl+Shift+A or choose Help | Find Action from the main menu.
Find and open the Registry editor.
Modify the value of the
Click Close and restart CLion for the changes to take effect.
Alternatively, you can pass the
localHistory.daysToKeep parameter as a Java property by configuring JVM options. For example, to set retention to 30 days, add the following line to the JVM options file:
Location of Local History files
Local History is stored as binary files under the LocalHistory subdirectory in the CLion system directory:
You can change the location of the system directory using the idea.system.path property.
Watch this video for a live demonstration of Local History features: