DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Can You Avoid the Git ‘Fatal: Refusing to Merge Unrelated Histories’ Error?
  • A Primer on the History and Evolution of Incident Management to Today
  • History of SRE: Why Google Invented the SRE Role
  • The 7 Most Expensive Bugs in History

Trending

  • How to Submit a Post to DZone
  • Log Analysis Using grep
  • Automated Testing Lifecycle
  • TDD With FastAPI Is Easy

Using Local History to Restore Deleted Files

Have you ever experienced this disappointment, when you suddenly find out that some of your most indispensable files are lost?

Irina Megorskaya user avatar by
Irina Megorskaya
·
Feb. 08, 08 · Tutorial
Like (1)
Save
Tweet
Share
27.49K Views

Join the DZone community and get the full member experience.

Join For Free

Have you ever experienced this disappointment, when you suddenly find out that some of your most indispensable files are lost? You might have fallen into this trap while synchronizing your local working copy of a project with the repository, or making some very last change before commit and breaking something else, or just accidentally deleting or overwriting a file. Well, you can try to restore the deleted files from your version control system… but it goes only as far as tracking the committed revisions. You can also try to rummage about the recycle bin, and lucky you are, if your files are still there…

This is where IntelliJ IDEA’s local history on the project or folder level comes to help. With this effective feature, you can bring back your files without leaving IDEA. Local history for a project or folder preserves all modifications that affect the nested files, including the changes to the contents and to the file tree in general. Each change is marked with its time stamp, revision, and action description. Unlike version control that keeps track of the committed revisions only, the local history preserves all local changes you make as you edit, compile or test, during few days (it is up to you to define how long you want this history to be). This “personal version control” will help us restore the deleted file.

In the example below, a file Lost.txt has been deleted from the FontChooser project. Let’s try to restore it. Go to the Project tool window and right-click the project node or just a folder, where the file used to exist:

[img_assist|nid=868|title=|desc=|link=none|align=left|width=409|height=255]

On the context menu, choose Local History, and click Show History on the submenu:

[img_assist|nid=869|title=|desc=|link=none|align=left|width=524|height=101]

The local history view for a project or folder shows you everything that you have done during the last few days. In the Action column of the lower part of the dialog box, select the action you want to roll back. In our case, this is the “Deleting” action. So doing, the upper part of the dialog box shows the tree view of changed files.

If you want to restore the deleted file only, regardless of the other changes that have been done since then, you can select the file Lost.txt in the tree view and click the Revert button on the upper toolbar. The file will be restored silently.

[img_assist|nid=871|title=|desc=|link=none|align=left|width=429|height=369]

A different situation occurs, if you want to restore the deleted file and the whole project or folder state as of a certain revision. In this case, place the cursor on the revision prior to the “Deleting” action, or on the action itself, and click the Revert button on the lower toolbar.

[img_assist|nid=872|title=|desc=|link=none|align=left|width=434|height=372]

If the other files have been changed since the “Deleting” action, you will be prompted that the other changes will be reverted too. Look again at the Project view – our file is here:

[img_assist|nid=873|title=|desc=|link=none|align=left|width=250|height=207]

History (command)

Opinions expressed by DZone contributors are their own.

Related

  • Can You Avoid the Git ‘Fatal: Refusing to Merge Unrelated Histories’ Error?
  • A Primer on the History and Evolution of Incident Management to Today
  • History of SRE: Why Google Invented the SRE Role
  • The 7 Most Expensive Bugs in History

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: