Shelve and unshelve changes搁置更改和取消搁置更改
Shelving is temporarily storing pending changes you have not committed yet. 搁置是临时存储尚未提交的挂起更改。This is useful, for example, if you need to switch to another task, and you want to set your changes aside to work on them later.例如,如果您需要切换到另一个任务,并且希望将所做的更改放在一边,以便以后处理,这将非常有用。
With WebStorm, you can shelve both separate files and entire changelists.使用WebStorm,您可以搁置单独的文件和整个变更列表。
Once shelved, a change can be applied as many times as you need.一旦搁置,可以根据需要多次应用更改。
Shelve changes搁置更改
-
In the Commit tool window Alt+0, right-click the files or the changelist you want to put to a shelf and select Shelve changes from the context menu.在“提交”工具窗口Alt+0中,右键单击要放置到搁置架的文件或更改列表,然后从关联菜单中选择“搁置更改”。 -
In the Shelve Changes dialog, review the list of modified files.在“搁置更改”对话框中,查看已修改文件的列表。 -
In the Commit Message field, enter the name of the shelf to be created and click the Shelve Changes button.在“提交消息”字段中,输入要创建的搁置架的名称,然后单击“搁置更改”按钮。
You can also shelve changes silently, without displaying the Shelve Changes dialog. To do this, select a file or a changelist you want to shelve, and click the Shelve Silently icon 也可以静默搁置更改,而不显示“搁置更改”对话框。要执行此操作,请选择要搁置的文件或变更列表,然后单击工具栏上的“静默搁置”图标 on the toolbar, or press Ctrl+Shift+H.
,或按Ctrl+Shift+H。
The name of the changelist containing the changes you want to shelve will be used as the shelf name.包含要搁置的更改的更改列表的名称将用作搁置名称。
To avoid ending up with numerous shelves with the same name (such as Default, for example), you can drag a file or a changelist from the Local Changes view to the Shelf tab, wait a second until it's activated, and edit the new shelf name on-the-fly when you release the mouse button.为避免出现多个具有相同名称的搁置架(例如,默认),可以将文件或更改列表从“本地更改”视图拖动到“搁置架”选项卡,等待一秒钟直到激活,然后在释放鼠标按钮时动态编辑新的搁置名称。
Unshelve changes取消搁置更改
Unshelving is moving postponed changes from a shelf to a pending changelist. 取消搁置是将延迟的更改从搁置架移动到挂起的更改列表。Unshelved changes can be filtered out from view or removed from the shelf.未搁置的更改可以从视图中筛选出来或从搁置架中删除。
-
In the Shelf tab, select the changelist or the files you want to unshelve.在“搁置架”选项卡中,选择要取消搁置的更改列表或文件。 -
Press Ctrl+Shift+U or choose Unshelve from the context menu of the selection.按Ctrl+Shift+U或从所选内容的关联菜单中选择“取消搁置”。 -
In the Unshelve Changes dialog, specify the changelist you want to restore the unshelved changes to in the Name field.在“取消搁置更改”对话框中,在“名称”字段中指定要将取消搁置的更改还原到的更改列表。You can select an existing changelist from the list or enter the name for a new changelist to be created containing the unshelved changes.您可以从列表中选择现有变更列表,或输入要创建的包含未搁置变更的新变更列表的名称。You can enter the description of the new changelist in the Comment field (optional).您可以在“注释”字段(可选)中输入新变更列表的说明。If you want to make the new changelist active, select Set active.如果要激活新变更列表,请选择“设置为激活”。Otherwise, the current active changelist remains active.否则,当前激活的变更列表将保持激活状态。 -
If you want WebStorm to preserve the context of a task associated with the new changelist on its deactivation and restore the context when the changelist becomes active, select the Track context option (see tasks and contexts for details).如果希望WebStorm在停用时保留与新变更列表关联的任务的上下文,并在变更列表变为活动状态时恢复上下文,请选择“跟踪上下文”选项(有关详细信息,请参阅任务和上下文)。 -
If you want to remove the changes you are about to unshelve, select the Remove successfully applied files from the shelf option.如果要删除要取消搁置的更改,请选择“从搁置中删除成功应用的文件”选项。The unshelved files will be removed from this shelf and added to another changelist and marked as applied.取消搁置的文件将从此搁置架中删除,并添加到另一个变更列表中,并标记为已应用。They will not be removed completely until deleted explicitly by clicking只有通过单击工具栏上的on the toolbar, or selecting Clean Already Unshelved from the context menu.
或从关联菜单中选择“清除已取消的搁置”来明确删除它们,它们才会被完全删除。
-
Click OK.单击“确定”。If conflicts occur between the patched version and the current version, resolve them as described in Resolve conflicts.如果修补版本与当前版本之间发生冲突,请按照“解决冲突”中的说明解决冲突。
You can also unshelve changes silently, without displaying the Unshelve Changes dialog. 也可以静默取消搁置更改,而不显示“取消搁置更改”对话框。To do this, select a file or a changelist you want to unshelve, and click the Unshelve Silently icon 要执行此操作,请选择要取消搁置的文件或变更列表,然后单击工具栏上的“静默取消搁置”图标 on the toolbar, or press Ctrl+Alt+U.
,或按Ctrl+Alt+U。
The unshelved files will be moved to the active pending changelist.取消搁置的文件将移动到活动的挂起更改列表中。
You can also drag a file or a changelist from the Shelf tab to the Local Changes view to unshelve it silently. 也可以将文件或变更列表从“搁置架”选项卡拖动到“本地变更”视图,以静默方式取消搁置。If you drag it holding the Ctrl key, it will be copied to the Local Changes tab instead of being removed from the shelf.如果按住Ctrl键拖动它,它将复制到“本地更改”选项卡,而不是从搁置架中删除。
Discard shelved changes放弃搁置的更改
-
In the Shelf view, select the changelist that contains the changes you do not want to keep any more.在搁置架视图中,选择包含您不想再保留的更改的更改列表。 -
Right-click it and choose Delete from the context menu, or press Delete.右键单击它并从关联菜单中选择“删除”,或按Delete键。
Restore unshelved changes恢复未搁置的更改
WebStorm lets you reapply unshelved changes if necessary. WebStorm允许您在必要时重新应用取消搁置的更改。All unshelved changes can be reused until they are removed explicitly by clicking the 通过单击工具栏上的 icon on the toolbar, or selecting Clean Already Unshelved from the context menu.
图标,或从关联菜单中选择“清除已取消的搁置”,可以重复使用所有取消搁置的更改,直到它们被明确删除为止。
-
Make sure that the Show Already Unshelved确保已启用“显示已取消搁置”toolbar option is enabled.
的工具栏选项。
-
Select the files or the shelf you want to restore.选择要恢复的文件或搁置架。 -
From the context menu of the selection, choose Restore.从所选内容的关联菜单中,选择“还原”。
Apply external patches应用外部补丁
You can import patches created inside or outside WebStorm and apply them as shelved changes.您可以导入在WebStorm内部或外部创建的修补程序,并将其作为搁置的更改应用。
-
In the Shelf view, choose Import Patches from the context menu.在“搁置架”视图中,从关联菜单中选择“导入修补程序”。 -
In the dialog that opens, select the patch file to apply.在打开的对话框中,选择要应用的修补程序文件。The selected patch appears in the Shelf tab as a shelf.选定的修补程序将作为搁置架显示在“搁置架”选项卡中。 -
Select the newly added shelf with the patch and choose Unshelve Changes from the context menu of the selection.选择带有修补程序的新添加搁置架,然后从所选内容的关联菜单中选择“取消搁置更改”。
Automatically shelve base revision自动搁置基础修订
It may be useful to configure WebStorm to always shelve base revisions of files that are under Git version control.将WebStorm配置为始终搁置Git版本控制下的文件的基本修订版可能很有用。
Press Ctrl+Alt+S to open IDE settings and select Version Control | Shelf.按Ctrl+Alt+S打开IDE设置并选择“版本控制”|“搁置架”。-
Select the Shelve base revisions of files under distributed version control systems option.选择“分布式版本控制系统下的文件搁置库修订”选项。If this option is enabled, the base revision of files will be saved to a shelf that will be used during a 3-way merge if applying a shelf leads to conflicts.如果启用此选项,则文件的基本修订版将保存到搁置架,如果应用搁置架导致冲突,则将在三方合并期间使用该搁置架。If it is disabled, WebStorm will look for the base revision in the project history, which may take a while; moreover, the revision that the conflicting shelf was based on may be missing (for example, if the history was changed as a result of the rebase operation).如果禁用,WebStorm将在项目历史记录中查找基础修订,这可能需要一段时间;此外,冲突搁置架所基于的修订可能会丢失(例如,如果历史记录因重新基准操作而更改)。
Change the default shelf location更改默认搁置架位置
By default, the shelf directory is located under your project directory. 默认情况下,搁置架目录位于项目目录下。However, you may want to change the default shelf location. 但是,您可能需要更改默认搁置架位置。This can be useful, for example, if you want to avoid deleting shelves accidentally when cleaning up your working copy, or if you want to store them in a separate repository allowing shelves to be shared among your team members.例如,如果您希望在清理工作副本时避免意外删除搁置架,或者希望将它们存储在单独的存储库中,以便在团队成员之间共享搁置架,则这可能非常有用。
Press Ctrl+Alt+S to open IDE settings and select Version Control | Shelf.按Ctrl+Alt+S打开IDE设置并选择“版本控制”|“搁置架”。-
Click Change Shelves Location and specify the new location in the dialog that opens.单击“更改搁置架位置”,并在打开的对话框中指定新位置。 -
If necessary, select Move shelves to the new location to move existing shelves to the new directory.如有必要,请选择“将搁置架移动到新位置”,以将现有搁置架移动到新目录。
Watch this video tutorial on how to benefit from shelves to be able to switch to a different task without losing unfinished work:观看本视频教程,了解如何从搁置架中获益,以便在不丢失未完成工作的情况下切换到其他任务: