WebStorm 2021.2 Help

Manage files under version control在版本控制下管理文件

Add files to VCS向VCS添加文件

  1. Open the Commit tool window Alt+0打开提交工具窗口Alt+0

  2. Put any files in the Unversioned Files changelist under version control by pressing Ctrl+Alt+A or selecting Add to VCS from the context menu. Ctrl+Alt+A或从上下文菜单中选择“添加到VCS”,将未版本文件更改列表中的任何文件置于版本控制下。You can either add the entire changelist, or select separate files.您可以添加整个变更列表,也可以选择单独的文件。

If you have enabled VCS integration for your project, WebStorm suggests to add each newly created file under version control (you can change this behavior in the Settings/Preferences dialog Ctrl+Alt+S under Version Control | Confirmation). 如果您已为项目启用VCS集成,WebStorm建议在版本控制下添加每个新创建的文件(您可以在版本控制下的“设置”/“首选项”对话框Ctrl+Alt+S中更改此行为|确认)。If you want certain files to always remain unversioned, you can configure your VCS to ignore them.如果您希望某些文件始终保持不变,可以将VCS配置为忽略它们。

All the settings files in the .idea directory should be put under version control except workspace.xml, which stores your local preferences. .idea目录中的所有设置文件都应置于版本控制之下,除了存储本地首选项的workspace.xmlThe workspace.xml file should be marked as ignored by VCS.workspace.xml文件应标记为被VCS忽略。

Check project files status检查项目文件状态

WebStorm allows you to check the status of your local working copy compared to the repository version of the project. WebStorm允许您检查本地工作副本的状态,并与项目的存储库版本进行比较。It lets you see which files have been modified, which new files have been added to the VCS, and which files are not being tracked by Git.它允许您查看哪些文件已被修改,哪些新文件已添加到VCS,哪些文件未被Git跟踪。

Open the Commit tool window Alt+0打开“提交”工具窗口Alt+0

Files with various statuses in the Version Control tool window
  • The Default changelist shows all files that have been modified since you last synchronized with the remote repository (highlighted in blue), and all new files that have been added to the VCS but have not been committed yet (highlighted in green).默认”更改列表显示自上次与远程存储库同步以来已修改的所有文件(以蓝色突出显示),以及已添加到VCS但尚未提交的所有新文件(以绿色突出显示)。

  • The Unversioned Files changelist shows all files that have been added to your project, but that are not being tracked by Git.未版本文件更改列表显示已添加到项目中但未被Git跟踪的所有文件。

You can perform deployment tasks, such as uploading files and folders or comparing them with deployed versions, directly from the Local Changes tab of the Version Control tool window. 您可以直接从版本控制工具窗口的本地更改选项卡执行部署任务,例如上载文件和文件夹,或将其与部署的版本进行比较To do this, right-click an item and select Deployment from the context menu. 要执行此操作,请在项目上单击鼠标右键,然后从关联菜单中选择“部署”。Then choose the desired action from the submenu.然后从子菜单中选择所需的操作。

Track changes to a file in the editor在编辑器中跟踪对文件的更改

You can also track changes to a file as you modify it in the editor. 在编辑器中修改文件时,还可以跟踪对文件的更改。All changes are highlighted with change markers that appear in the gutter next to the modified lines, and show the type of changes introduced since you last synchronized with the repository. 所有更改都将使用更改标记高亮显示,这些标记显示在修改行旁边的檐槽中,并显示自上次与存储库同步以来引入的更改类型。When you commit changes to the repository, change markers disappear.将更改提交到存储库时,更改标记将消失。

The changes you introduce to the text are color-coded:您对文本所做的更改以颜色编码:

  • marker for a newly added line line added.添加的行。

  • marker for a modified line line changed.更改的行。

  • marker for a deleted line line deleted.删除的行。

You can manage changes using a toolbar that appears when you hover the mouse cursor over a change marker and then click it. 您可以使用将鼠标光标悬停在更改标记上,然后单击该标记时显示的工具栏来管理更改。The toolbar is displayed together with a frame showing the previous contents of the modified line:工具栏将与显示修改行以前内容的框架一起显示:

the modified line marker

You can roll back changes by clicking the Revert icon and explore the differences between the current and the repository version of the current line by clicking the Show diff icon.您可以通过单击the Revert icon回滚更改,并通过单击the Show diff icon查看当前行的当前版本和存储库版本之间的差异。

Instead of reverting the whole file, you can copy any part of the contents of this popup and paste it into the editor.您可以复制此弹出窗口的任何部分内容并将其粘贴到编辑器中,而不是还原整个文件。

Delete files from the repository从存储库中删除文件

If you delete a file that is under version control, it still exists in the repository until you've committed the changes. 如果删除受版本控制的文件,则在提交更改之前,该文件仍然存在于存储库中。The deleted file is placed to the active changelist, and is highlighted with grey.删除的文件将被放置到活动的变更列表中,并以灰色突出显示。

  1. >Select a file in the Project tool window, and press Delete, or choose Delete from the context menu.>在“项目工具”窗口中选择一个文件,然后按Delete键,或从关联菜单中选择“删除”。

  2. In the dialog that opens, you can choose whether you want to delete this file without searching for usages, or to perform safe delete to make sure that you are deleting an unused file by checking the Safe delete option.在打开的对话框中,您可以选择是在不搜索用法的情况下删除此文件,还是执行“安全删除”以确保通过选中安全删除选项删除未使用的文件。

    If any usages have been found, the Usages Detected dialog will popup listing them. You can view these usages and remove references to this file before deleting it.如果发现任何用法,将弹出“检测到的用法”对话框,列出它们。您可以查看这些用法,并在删除此文件之前删除对此文件的引用。

  3. Commit the changes to the repository.将更改提交到存储库。

Last modified: 08 March 2021