You can also create a patch by invoking the Commit Changes dialog, selecting the changes you want to include in the patch, hovering the mouse cursor over the Commit button and selecting Create Patch.

If you do not need to save a patch to a file, and want, for example, to send it by email or through a messenger, you can select Copy as Patch to Clipboard from the context menu of the selected file or changelist, and then paste it to a message body.

You can also create a patch based on changes that have already been committed. To create a patch from an entire commit, locate it in the Log view, and select Create Patch from the context menu. If you need to create a patch on a single file, and the corresponding commit contains multiple files, do the following:

Select the required file in any view (in the Project tool window, in the editor, in the Local Changes tab of the Version Control tool window, an son 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 Version Control tool window.

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

Apply a patch

To apply changes stored in a file to your sources, do the following:

Select VCS | Apply patch from the main menu.

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

You can drag a file or an email attachment to any place in the editor.

If necessary, click the Map base directory icon 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.

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 the Show Diff icon or press Ctrl+D. If there are conflicts, the corresponding lines will be highlighted in red.

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 using the Strip Directory button .

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.

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

If you want RubyMine 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 Managing tasks and contexts for details).

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, RubyMine extracts the commit message and the author and automatically fills the corresponding fields in the Commit Changes dialog.