JetBrains Rider 2022.2 Help

Use patches

Instead of committing your local changes, you can put them in a .patch file that you can apply to your sources later, send by email, and so on. Using patches is a convenient mechanism for sharing changes without checking them into to a VCS repository.

Create a patch from uncommitted changes

  1. In the Local Changes view, select the file or the changelist based on which you want to create a patch, and choose Create Patch from Local Changes from the context menu.

    You can also select the changes for commit, click the arrow next to the Commit button and select Create Patch.

  2. In the dialog that opens, make sure that all changes you want to include in the patch are selected, enter a commit comment (optionally) and click Create Patch.

  3. In the Patch File Settings dialog, modify the default patch file location if necessary, and click OK.

If you do not need to save the patch to a file, and want, for example, to send it by email or through a messenger, you can right-click a file in the Commit window and choose Copy as Patch to Clipboard from the context menu.

Create a patch from an entire commit

  1. Locate the commit that you want to create a patch from in the Log tab of the Version Control tool window Alt+9 and select Create Patch from the context menu.

  2. In the Patch File Settings dialog, modify the default patch file location if necessary, and click OK.

Create a patch from a file

  1. Select the required file in any view (in the Solution Explorer, in the editor, in the Commit window , and so on).

  2. 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.

  3. Right-click a revision and choose Create Patch from the context menu, or click the Create Patch icon the Apply Patch icon on the toolbar.

Apply patches

  1. Select VCS | Patch | Apply patch from the main menu.

  2. In the Apply Patch dialog that opens, specify the path to the .patch file you want to apply.

  3. If necessary, click the folders icon and choose Map Base Directory to specify a directory relative to which file names in the patch file will be interpreted. You can map a base directory to a single file, directory, or to a selection.

  4. If the source code was edited after a patch was created, conflicts may arise. To check if you patch can be applied without conflicts, click Show Diff the Show diff icon Ctrl+D. If there are conflicts, the corresponding lines will be highlighted with red.

  5. If you want to apply changes to files stored in different locations from those specified in the patch, you can strip off the leading directories by clicking the folders icon and choosing Remove All Leading Directories.

  6. Select an existing changelist where you want to add the patch from the list, or specify the name of a new changelist in the Name field, and, optionally, enter a comment to this changelist.

  7. If you want to make this changelist active, select the Set active option.

  8. If you want JetBrains Rider 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 Manage tasks and contexts for details) .

  9. If you want to move the patch to a temporary storage (shelf) before applying it, click Import to shelf (see Shelve and unshelve changes for details). Otherwise, click OK.

You can also copy a patch file content and apply it by choosing VCS | Apply Patch from Clipboard from the main menu. This is convenient when you receive a patch by email, for example, and do not want to save it. For Git format patches, JetBrains Rider extracts the commit message and the author and automatically fills the corresponding fields in the Commit tool window .

Last modified: 08 August 2022