Compare file and folder versions using Diff viewer
JetBrains Rider allows you to examine the differences between two revisions of a file/folder or between their current local copy and the repository version. The differences are displayed in the Diff Viewer.
Compare a modified file with its Git repository version
Open the Commit tool window .
Locate the required file in a changelist and do one of the following:
Right-click the file and select
.Select the file and press Ctrl+D.
Double-click the file.
The diff view opens where changes to the file are highlighted.
The right pane contains the modified version of the file. You can edit it in the diff view.
The left pane contains the initial version of the file. It is read-only. You can click (Revert) to undo a change.
Compare the current revision of a file or folder with a revision in the same Git branch
Select a file or a folder in the Solution Explorer, and choose
from the context menu.Choose a revision you want to compare the current file or folder version with from the dialog that opens.
Compare the current revision of a file or folder with another Git branch
Select a file or a folder in the Solution Explorer, and choose
from the context menu.Choose the branch you want to compare the current file or folder version with from the dialog that opens.
Compare local changes with the base revision
Apart from navigating through your local changes within a file in the editor, you can review these changes compared to the base revision of the file.
To preview the diff, select a modified file in the Commit tool window and click on the toolbar.
The left pane shows the affected code as it was in the base revision, and the right page shows the affected code after you've made changes locally.
Use the toolbar buttons and controls to navigate between changes and configure the appearance of the Change Details pane or the Diff Viewer:
Item | Tooltip and Shortcut | Description |
---|---|---|
/ | Previous Difference / Next Difference Shift+F7 F7 | Jump to the next or previous difference. When the last or the first difference is reached, JetBrains Rider suggests clicking the arrow buttons or pressing F7/Shift+F7 once more and comparing other files modified locally. This behavior depends on the Go to the next file after reaching last change option in the Diff Viewer settings. |
Jump to Source F4 | Open the selected file in the editor. The caret is placed in the same position as in the Diff Viewer. | |
Compare Previous/Next File Alt+LeftAlt+Right | Compare the local copy of the previous or next file with its update from the server. | |
| Go To Changed File Ctrl+N | Display all changed files in the current change set and navigate to them. This action is only available when you review changes to multiple files. |
Viewers | Select a viewer mode: side-by-side or unified. The side-by-side mode has two panels, and the unified mode has one panel. You can edit code and perform the Accept, Append, Revert actions in both viewers. You can change text only in the right-hand part of the side-by-side viewer or in the lower line in the unified viewer. You can edit only local versions of your files. You cannot edit files that have read-only status. | |
Whitespace | Define how the Diff Viewer should treat whitespaces.
| |
Highlighting mode | Select the way differences granularity is highlighted. The available options are:
| |
Collapse Unchanged Fragments | Collapse all the unchanged fragments in both files. The amount of non-collapsible unchanged lines is configurable on the Diff & Merge settings page. To open the Diff & Merge page, open settings by pressing Ctrl+Alt+S and navigate to . . | |
Synchronize Scrolling | Click this button to scroll both differences panes simultaneously. If this button is released, each of the panes can be scrolled independently. | |
Settings | Open a list of available settings. These commands are also available from the context menu of the Diff Viewer gutter. | |
Show diff in external tool | Invoke an external diff viewer specified on the External Diff Tools settings page. This button is available only on the toolbar when the Use external diff tool option is enabled on the External Diff Tools settings page. | |
Help F1 | Open a browser and show the corresponding help page. | |
Annotate with GitBlame | This option is only available from the context menu of the gutter. Use this option to explore who introduced which changes to the repository version of the file and when. The annotations view lets you see detailed information for each line of code, such as the version from which this line originated, the ID of the user who committed this line, and the commit date. For more information about annotations, refer to Locate code author (Annotate with Git Blame). |
The most useful shortcuts are the following:
Shortcut | Description |
---|---|
Ctrl+Shift+D | Use this keyboard shortcut to show the popup menu of the most commonly used diff commands. |
Ctrl+Shift+Tab | Use this keyboard shortcut to switch between the left and the right panes. |
Ctrl+Z/Ctrl+Shift+Z | Use this keyboard shortcut to undo/redo a merge operation. Conflicts will be kept in sync with the text. |