Phpstorm вернуть удаленный файл
You can always undo the changes you've made locally before you commit them:
In the Commit tool window Alt+0 , select one or more files that you want to revert, and select Rollback from the context menu, or press Ctrl+Alt+Z . All changes made to the selected files since the last commit will be discarded, and they will disappear from the active changelist.
Location of Local History files
Local History is stored as binary files under the LocalHistory subdirectory in the PhpStorm system directory:
PhpStorm automatically saves changes that you make in your files. Saving is triggered by various events, such as running, debugging, performing version control operations, closing a file or a project, or quitting the IDE. Saving files can be also triggered by third-party plugins.
Most of the events that trigger auto-save are predefined and cannot be configured, but you can be sure that changes will not be lost and you can find all of them in local history.
Drop a commit
Unlike reverting a commit, which is reflected in the branch history, you can discard a pushed commit in the current branch without leaving any traces of the operation.
Like any operation that rewrites a branch history, dropping a commit requires a --force push and cannot be performed in protected branches (these can be configured in the Version Control | Git page of the IDE settings Ctrl+Alt+S .
Select a commit you want to discard in the Log view and choose Drop Commit from the context menu.
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, and so on. 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.
Select File | Local History | Put Label from the main menu.
In the dialog that opens, type any meaningful name for the label and click OK .
3 ответа 3
Может вы каким то образом Local History отменили или работали с файлами которые не являются файлами проекта. Обычно Local History хорошо всё контролирует и решает данную проблему
Local History показывает только изменения того файла, вкладка которого активна. И откатить может изменения только этого файла. А если изменено несколько файлов? Откатить сразу все как? Каждый из них открывать и откатывать? Должны быть другие средства.
В PHPStorm нажмите комбинацию клавиш Alt + 9 (Либо в меню нажмите View затем Tool windows , и там найдите Version Control ), откроется окно Local Changes.
Там просто выбираем файлы, которые хотим отменить и нажимаем правой клавишей мыши и выбираем Revert.
А как выбрать файлы? Нужно лазить в дереве проекта и открывать каждый файл, который я хочу "откатить"? И у него смотреть Local History? Ведь Local History показывает только тот файл, вкладка которого активна. Или там можно как-то переключаться между файлами? Прикладываю скриншот. Открыта вкладка файла style.css. Local History и показывает изменения в нем. Если нажму Revert, откатится только он (даже если нажал Revert у пункта с 3 файлами). ibb.co/cMZSNG
@AlexandrNevajno я у себя в окне Local Changes просто выбираю файлы, которые хочу откатить и нажимаю кнопку Revert - все исправно работает (отмена массового изменения). Не знаю, что у вас за беда. у меня официальная лицензия на PHPStorm. И не понимаю, зачем лазить в дереве и искать, вы просили массовую отмену - вот она, жмите хоть Ctr+A и отменяйте - все работает.
@AlexandrNevajno я вообще-то не про Local History говорю, а про Local Changes - это немного не то. Local History находится на вкладке VCS->Local History->Show History
@AlexandrNevajno посмотрите внимательно в мой ответ, я там подробно описал как туда попасть. Local History и Local Changes - разные пункты.
Это нужно смотреть, какие файлы менялись во время Replace in Path. И перед самой операцией Replace in Path нужно эти файлы как-то сохранить (чтобы было к чему Revert'ить), да?
Я научился отменять изменения во всех файлах в PhpStorm. Просто нужно нажать Ctrl+Z. Там выскочит диалоговое окно - "Undo Replace"? Жмем OK. И отменяются изменения во ВСЕХ файлах. Если делать через VCS->Local History->Show History, то только в одном файле. Жаль, что нельзя через историю - если после массового изменения были еще какие-то изменения, то их тоже придется отменить - чтобы дойти до массового изменения.
Save changes manually
You can always save your changes manually:
Press Ctrl+S or select File | Save All from the main menu.
Change Local History retention period
By default, Local History is configured to store revisions for the last 5 working days (that is, days when the file was modified).
In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Advanced Settings .
In the IDE section, provide the desired retention period value in the Duration of storing changes in Local History field.
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:
If you want to disable Local History completely, set the retention period to 0 .
Всё ещё ищете ответ? Посмотрите другие вопросы с метками phpstorm ide или задайте свой вопрос.
Похожие
Для подписки на ленту скопируйте и вставьте эту ссылку в вашу программу для чтения RSS.
Site design / logo © 2022 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2022.5.11.42086
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.
Что вообще можно сделать ? почему PhpStorm повредил файл ?
VCS -> Local History -> Show History
Используйте Git(или аналог) и таких проблем не будет.
история пустая там ничего нет, изменил один файл появилось, а старой истории вообще нет хотя весь проект с самого начала разрабатывал в PHPstorm
winser: Тогда увы, ищите как восстановить. Прислушайтесь к совету о Git. Мы как-то потеряли 2 недели работы. С Git-ом у вас никогда такого не будет.
Не PhpStorm, а ОС.
Синий экран шторм вызвать не может.
Про локальную историю вам уже сказали.
И научитесь пользоваться git, тогда потери будут на несколько часов вместо дней и недель.
Вот в точности такая же проблема была пару дней назад, но с другим продуктом от JetBrains -- PyCharm.
Я восстановил файл с помощью R-Studio.
тоже самое только то что произошло в phpstorm 7, потерялось локальное хистори и один файл с классом. жесть.
кто знает, где phpstorm хранит локальную историю?
Востановление ветки в другом продукте от JetBrains - Webstorm. Использую Git.
Предисторрия.
Работал над одной таской на отдельной ветке, послее ее завершения вмержил в дев ветку для проверки. шло время, ветки с таскоми копились, решил почистить, удалил и эту с фичей, как обычно бывает, после этого, проверили фичу и попросили ливануть ее на стейдж ветку, а ветки то и нет, так вот как вариант А:
git log список коммитов
номер одного коммита
переходишь на ту ветку, куда хочешь их пернести
git cherry-pick
вариант Б:
Правой кнопкой > Git > Show History
вкладка log. через поиск находишь свои сохранения на ветке
origin &
жмешь на название > chekout и. вуаля ветка опять жива
Unstage files
By default, PhpStorm uses the changelists concept where modified files are staged automatically.
If a file is already under version control and you do not want to commit it, you can:
Remove it from the commit: do not select it in the Changes area of the Commit tool window.
If you are more used to the staging concept, select the Enable staging area option in the Version Control | Git page of the IDE settings Ctrl+Alt+S .
Also, by default PhpStorm suggests adding each newly created file under version control. You can change this behavior in Settings/Preferences | Version Control | Confirmation using When files are created and When files are deleted settings respectively.
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.
Unstage files
By default, PhpStorm uses the changelists concept where modified files are staged automatically.
If a file is already under version control and you do not want to commit it, you can:
Remove it from the commit: do not select it in the Changes area of the Commit tool window.
If you are more used to the staging concept, select the Enable staging area option in the Version Control | Git page of the IDE settings Ctrl+Alt+S .
Also, by default PhpStorm suggests adding each newly created file under version control. You can change this behavior in Settings/Preferences | Version Control | Confirmation using When files are created and When files are deleted settings respectively.
Undo the last commit
PhpStorm allows you to undo the last commit in the current branch.
You cannot undo a commit if it was pushed to a protected branch, that is a branch to which force --push is not allowed (configure protected branches in the Version Control | Git page of the IDE settings Ctrl+Alt+S ) Note that if a branch is marked as protected on GitHub, PhpStorm will automatically mark it as protected when you check it out.
Open the Git tool window Alt+9 and switch to the Log tab.
Select the last commit in the current branch and choose Undo Commit from the context menu.
In the dialog that opens, select a changelist where the changes you are going to discard will be moved. You can either select an existing changelist from the Name list, or specify the name of a new changelist (the commit message is used by default).
Select the Set active option if you want to make the changelist with the changes you are about to discard the active changelist.
Select the Track context option if you want PhpStorm to remember your context and reload currently opened files in the editor when this changelist becomes active.
Revert selected changes
PhpStorm lets you undo selected changes from a pushed commit if this commit contains multiple files and you only need to revert some of them.
In the Log view select the commit containing the changes you want to discard.
In the Changed Files pane, right-click the file that you want to revert and select Revert Selected Changes from the context menu.
This results in a new commit that reverses the changes you want to undo.
Restore changes
Let's imagine you made a series of changes to a file since your last commit before your realized you've deleted a meaningful chunk of code. The Undo action can't help you here because that change is too far away and you'll be forced to discard other changes if you use it.
With PhpStorm you can restore that change in a couple of clicks.
Right-click anywhere in the editor and choose Local History | Show History from the context menu.
In the dialog that opens, the left-hand pane shows a list of all saved revisions of the current file with timestamps. The right-hand pane shows a diff viewer which displays the differences between each revision and the current state of the file.
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 restore a specific code fragment, select the revision that contains that fragment. In the diff view on the right locate the piece of code you want to restore click the chevron button to copy it from the left pane.
Trigger actions when saving changes
In PhpStorm, you can configure the actions that will be triggered every time your modified files are saved.
In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Tools | Actions on Save .
Select the checkboxes next to the actions that you want to trigger on save:
Reformat code: reformat your code according to your current code style settings.
Optimize imports: remove unused imports and organize import statements according to your current code style settings.
Rearrange code: reorder code elements according to your current code style settings.
Run code cleanup: batch-apply quick-fixes from code cleanup inspections in the current inspection profile.
Update copyright notice: update information in copyright notices in project files.
Run eslint --fix: fix the detected problems with ESlint.
Enabling this option also enables Run eslint --fix on save.
File Watcher: run your configured file watchers.
Upload to default server: upload modified files to your default deployment server.
For some actions, you can configure the settings more precisely. To do so, hover the mouse pointer over an action and click the configuration link.
For example, for code reformatting, you can specify files and folders that you don't want to change. Hover the mouse pointer over the action and click Configure scope to exclude specific files and folders from reformatting.
You can also select whether to reformat the whole file or only modified lines.
Apply the changes and close the dialog.
Once the necessary actions are enabled, they will be automatically triggered on every save (autosave, explicit save invoked with Ctrl+S or by selecting File | Save All ) as you work with your project.
Configure autosave behavior
In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Appearance & Behavior | System Settings .
Under Autosave , configure the following options:
Save files when switching to a different application or a built-in terminal : Save all modified files when you switch from PhpStorm to a different application.
Save files if the IDE is idle for N seconds : Save all modified files at regular time intervals.
Apply the changes and close the dialog.
Restore deleted files
If you've accidentally deleted a file that was not under version control, you can restore it with Local History.
Select the node that contained the file you deleted in the Project tool window, right-click it and choose Local History | Show History from the context menu.
On the left, select the revision that contains the file you want to restore, right-click that file, and choose Revert Selection .
Reset a branch to a specific commit
If you notice an error in a set of recent commits and want to redo that part, you can roll back your repository to a specific state. This is done by resetting the current branch HEAD to a specified commit (and optionally resetting the index and working tree if you prefer not to reflect the undo in the history).
Open the Version Control tool window Alt+9 and switch to the Log tab.
Select the commit that you want to move HEAD onto and select Reset Current Branch to Here from the context menu.
In the Git Reset dialog that opens, select how you want your working tree and the index to be updated and click Reset :
Soft : all changes from commits that were made after the selected commit will be staged (that means they will be moved to the Local Changes view so that you can review them and commit later if necessary).
Mixed : changes made after the selected commit will be preserved but will not be staged for commit.
Hard : all changes made after the selected commit will be discarded (both staged and committed).
Keep : committed changes made after the selected commit will be discarded, but local changes will be kept intact.
Revert changes
For most recent changes, including refactorings, press Ctrl+Z or choose Edit | Undo from the menu.
For a more detailed view of past changes, use Local History.
For the most robust tracking of all changes, use a version control system.
PhpStorm - как отменить массовое изменение (ctrl+shift+h)?
В Local History этих изменений не видно.
В Netbeans есть групповая история, там пишутся такие изменения.
А в PhpStorm есть что-то подобное?
Revert a pushed commit
If you notice an error in a specific commit that has already been pushed, you can revert that commit. This operation results in a new commit that reverses the effect of the commit you want to undo. Thus, project history is preserved, as the original commit remains intact.
Locate the commit you want to revert in the Log tab of the Git tool window Alt+9 , right-click it and select Revert Commit from the context menu. This option is also available from the context menu of a commit in the file History view. The Commit Changes dialog will open with an automatically generated commit message.
If you apply this action to multiple commits selected in the Log view, a separate commit will be created to revert each of them.
If the selected commit contains several files, and you only need to revert some of them, deselect the files you do not want to touch.
Click Commit to commit a changeset that reverts the changes to the selected files in this particular commit.
Get a previous revision of a file
If you need to revert a single file instead of discarding a whole commit that includes changes to several files, you can return to a particular version of that file:
Select the required file in any view (in the Project tool window, in the editor, in the Local Changes view, and so on).
Select Git | Show History from the main VCS menu or from the context menu of the selection. The History tab is added to the Git tool window showing the history for the selected file and allowing you to review and compare its revisions.
When you've identified the revision you want to roll back to, select it in the list and choose Get from the context menu.
Local History helps you constantly track all changes made to a project independently of version control.
Unlike version control systems, which only keep track of the differences made between commits, Local History offers much more. It automatically records your project's state as you edit code, run tests, deploy applications, and so on, and maintains revisions for all meaningful changes made both from the IDE and externally.
Acting as your personal version control system, Local History lets you restore deleted files, bring back separate changes, or roll back to any state of a file even if no version control is enabled for your project yet, or if an unwanted change was made after your last commit. It may also serve as a recovery source if your computer restarts unexpectedly before you can take any action.
Note that Local History is not a replacement for a proper version control for long-term versioning. Local History is cleared when you install a new version of PhpStorm. It also has a retention period and maximum size, so revisions are not guaranteed to persist.
Mark files with unsaved changes
You can mark unsaved files with an asterisk (*) on the file tab:
In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | General | Editor Tabs .
Select the Mark modified (*) checkbox.
Apply the changes and close the dialog.
After that, the tab of the file in which you have unsaved changes will be marked with an asterisk.
If you use version control integration, names of all modified files will be also marked with a dedicated color on the file tab and in the Project tool window.
Читайте также: