Problem
When using the modal commit interface in IntelliJ-based IDEs, the partial commit selection (specific files, hunks, or lines) is not restored after a commit fails due to a pre-commit Git hook:
- With Use non-modal commit interface disabled (modal commit) and a pre-commit Git hook configured, modify files that contain both changes that pass the hook and changes that fail it.
- Invoke commit (Ctrl+K / ⌘K) — the modal commit dialog opens with all files fully selected.
- Manually select only the specific files, hunks, or lines that pass the hook.
- Click Commit — the commit fails as expected due to the pre-commit hook.
- Invoke commit again — the dialog reopens with all files fully selected; the previous partial selection is lost.
Expected result: The partial selection from the failed commit is restored on the next commit attempt.
Actual result: The selection is reset to all files and all changes.
Tracked in IJPL-243182.
Cause
In the modal commit interface, the dialog is closed after a failed commit. The partial selection state is not persisted between dialog invocations, so the next commit starts with the default selection (all changes).
The non-modal commit interface keeps the commit form open after a failed commit, which preserves the partial selection in place.
Resolution
Switch to the non-modal commit interface, which preserves the partial selection across failed commit attempts:
- Open Settings (Ctrl+Alt+S / ⌘,) | Version Control | Commit.
- Enable Use non-modal commit interface.
To restore the inline diff preview familiar from the modal interface:
- Open Settings | Advanced Settings.
- Disable Version Control | Enable Commit tool window.
With this option disabled, the non-modal commit is integrated into the Git tool window and includes a diff preview pane.
Alternative: Window view mode
The non-modal Commit tool window can be detached to closely resemble the modal commit dialog while retaining the state-preserving behavior:
- Open the Commit tool window.
- Click the gear icon (Show Options Menu) | View Mode | Window.
In Window view mode, the Commit tool window opens as an independent window and stays open after a failed commit, with the partial selection preserved.
Comments
0 comments
Please sign in to leave a comment.