Limits of partial staging and hunk-level commits in the IntelliJ IDEA Commit dialog
0 reputation · 10 Mar 2020, 12:38 UTC
0 reputation · 10 Mar 2020, 12:38 UTC
I am evaluating whether IntelliJ IDEA's built-in Git integration can fully replace a terminal workflow for a team that relies on fine-grained commits. The documented Commit dialog supports staging changes per file and per section, with a diff preview, and the Git tool window handles commit, push, pull, and branch operations.
The uncertainty is around the boundaries of that partial-staging support. Specifically, it is not clear to me whether selecting individual changed lines or hunks in the Commit dialog creates a true partial index (as git add -p would), or whether the IDE emulates it in a way that can diverge from the actual repository index when the same file is also modified from the command line or another tool.
Assume a recent IntelliJ IDEA version with the bundled Git plugin enabled and a standard local repository; edition differences (Community vs. Ultimate) may matter if any of this is gated.
35275 reputation · 10 Mar 2020, 16:03 UTC
Partial (hunk‑level) staging in the IntelliJ IDEA Commit dialog writes directly to the real Git index; it does not use a temporary commit mechanism. The dialog invokes the configured Git executable (or the bundled JGit fallback) with the equivalent of git add -p, so the staged changes match what you would get from the command line.
git commit (or git commit -S when signing is enabled) from that index, yielding a commit object identical to one created via git add -p followed by git commit in a terminal.git commit -S mechanism; it respects your GPG agent, gpg.program, and other Git‑configured signing settings, imposing no extra constraints beyond those required for CLI signing.The behavior above holds when the IDE is configured to use the system Git executable. If you have the IDE set to use the bundled JGit implementation (Settings → Version Control → Git → Path to git executable pointing to the internal JGit), hunk‑level staging may diverge in edge cases (e.g., unusual whitespace handling) because JGit’s patch logic is not identical to native Git’s.
git diff --cached to confirm that only the selected hunks appear staged.git show --format=raw <commit> and verify the GPG signature block is present.To give a definitive recommendation, please confirm whether you are using the system Git executable or the bundled JGit implementation in the IDE’s Git settings. This determines whether any subtle divergence from native git add -p behavior is possible.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.