{"id":23763,"date":"2008-01-28T05:17:56","date_gmt":"2008-01-28T10:17:56","guid":{"rendered":"https:\/\/blogs.jetbrains.com\/idea\/2008\/01\/using-local-history-to-restore-deleted-files\/"},"modified":"2018-06-03T15:37:46","modified_gmt":"2018-06-03T15:37:46","slug":"using-local-history-to-restore-deleted-files","status":"publish","type":"idea","link":"https:\/\/blog.jetbrains.com\/pt-br\/idea\/2008\/01\/using-local-history-to-restore-deleted-files","title":{"rendered":"Using Local History to restore deleted files"},"content":{"rendered":"<p>Suppose you have accidentally deleted a file from your project, and want to have it back. Sure, you can restore it using the file system, but IntelliJ IDEA suggests a better way to do it, without leaving the IDE.<br \/>\nThis is where IntelliJ IDEA&#8217;s <a href=\"http:\/\/www.jetbrains.com\/idea\/features\/local_history.html\" target=\"_blank\" rel=\"noopener\">local history<\/a> on the project or folder level comes to help,  preserving 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 &#8220;personal version control&#8221; will help us restore the deleted file.<br \/>\nIn the example below, a file <code>Lost.txt<\/code> has been deleted from the FontChooser project. Let&#8217;s try to restore it. Go to the <strong>Project<\/strong> tool window and right-click the project node or just a folder, where the file used to exist:<br \/>\n<img src='http:\/\/blogs.jetbrains.com\/idea\/wp-content\/img\/localhistory1.png' alt='' \/><br \/>\nOn the context menu, choose <strong>Local History<\/strong>, and click <strong>Show History<\/strong> on the submenu:<br \/>\n<img src='http:\/\/blogs.jetbrains.com\/idea\/wp-content\/img\/localhistory2.png' alt='' \/><br \/>\nThe local history view for a project or folder shows you everything that you have done during the last few days. In the <strong>Action <\/strong>column of the lower part of the dialog box, select the action you want to roll back. In our case, this is the &#8220;Deleting&#8221; action. So doing, the upper part of the dialog box shows the tree view of changed files.<br \/>\nIf you want to restore the deleted file only, regardless of the other changes that have been done since then, you can select the file <code>Lost.txt<\/code> in the tree view and click the <strong>Revert <\/strong> button <img src='http:\/\/blogs.jetbrains.com\/idea\/wp-content\/img\/revert.png' alt='' \/>  on the upper toolbar. The file will be restored silently.<br \/>\n<img src='http:\/\/blogs.jetbrains.com\/idea\/wp-content\/img\/localhistory3.png' alt='' \/><br \/>\nA 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 &#8220;Deleting&#8221;\u009d action, or on the action itself, and click the <strong>Revert <\/strong> button  <img src='http:\/\/blogs.jetbrains.com\/idea\/wp-content\/img\/revert.png' alt='' \/> on the lower toolbar. If the other files have been changed since the &#8220;Deleting&#8221; action, you will be prompted that the other changes will be reverted too. Look again at the <strong>Project <\/strong>view &mdash; our file is here:<br \/>\n<img src='http:\/\/blogs.jetbrains.com\/idea\/wp-content\/img\/localhistory5.png' alt='' \/><\/p>\n<div style=\"font-size: 10px; margin-top: 25px;\">Technorati tags: <a href=\"http:\/\/www.technorati.com\/tag\/IntelliJ+IDEA\" rel=\"tag noopener\" target=\"_blank\">IntelliJ IDEA<\/a>, <a href=\"http:\/\/www.technorati.com\/tag\/local+history\" rel=\"tag noopener\" target=\"_blank\">local history<\/a><\/div>\n","protected":false},"author":1152,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","categories":[601],"tags":[2920],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/idea\/23763"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/idea"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/types\/idea"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/users\/1152"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/comments?post=23763"}],"version-history":[{"count":0,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/idea\/23763\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/media?parent=23763"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/categories?post=23763"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/tags?post=23763"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/pt-br\/wp-json\/wp\/v2\/cross-post-tag?post=23763"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}