IntelliJ IDEA 2020.1 Help

Local History

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

  1. Find the file that you want to study and open it in the editor.

  2. Select VCS | Local History | Show History from the main menu or right-click anywhere in the file and choose Local History | Show History.

  3. 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

  1. Select a project node in the Project tool window.

  2. Select VCS | Local History | Show History from the main menu or right-click the node and choose Show Local History.

  3. This will bring up a dialog with the list of changes to the seleted 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 N/A 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 select Local History | Show History for Class from the context menu.

View Local History for a source code fragment

  1. Select a code fragment that you want to study.

  2. Right-click the selection and choose Local History | Show History for Selection from 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

  1. Select VCS | Local History | Put Label from the main menu.

  2. 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

  1. Select a revision in the left part of the Local History dialog.

  2. 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 the Revert icon 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 apply left next to the desired changes.

  3. 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.

  1. Select VCS | Local History | Put Label from the main menu.

  2. 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.

  1. Select a revision in Local History dialog and click Create Patch create patch on the toolbar.

  2. 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

  1. Press Ctrl+Shift+A or choose Help | Find Action from the main menu.

  2. Find and open the Registry editor.

  3. Modify the value of the localHistory.daysToKeep parameter.

  4. Click Close and restart IntelliJ IDEA 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:

-DlocalHistory.daysToKeep=30

Location of Local History files

Local History is stored as binary files under the LocalHistory subdirectory in the IntelliJ IDEA system directory:

Syntax
%LOCALAPPDATA%\JetBrains\<product><version>
Example
C:\Users\JohnS\AppData\Local\JetBrains\IntelliJIdea2020.1
Syntax
~/Library/Caches/JetBrains/<product><version>
Example
~/Library/Caches/JetBrains/IntelliJIdea2020.1
Syntax
~/.cache/JetBrains/<product><version>
Example
~/.cache/JetBrains/IntelliJIdea2020.1

You can change the location of the system directory using the idea.system.path property.

Last modified: 25 May 2020