Staging hunks and single lines

Taking part of a file into a commit and leaving the rest behind.

Sometimes a file holds two changes and only one of them belongs in this commit: the fix you meant to make, and the stray print you added while finding it. Innesta stages at three sizes, and the gutter of the diff is where the two smaller ones live.

Stage Hunk takes the whole block. The controls for a single line appear in the gutter as you point at it.

A hunk

A hunk is one contiguous run of changes with a little unchanged code around it — the unit Git itself works in. Stage Hunk above the hunk takes it and leaves the rest of the file where it was.

How much unchanged code surrounds a hunk is adjustable, and it matters here: widening the context can merge two hunks into one, and narrowing it can split one into two. See context and whitespace.

A single line

Each changed line has its own control in the gutter. Pressing it stages that line alone.

A block of lines

Dragging down the gutter gathers the lines you pass over and applies them as one step, rather than as one Git operation per line. On a long run that is the difference between one patch and twenty, which is both faster and less able to leave the index half-done if something goes wrong in the middle.

Reading it back

Once part of a file is staged and part is not, that file has changes on both sides. The All / Unstaged / Staged selector at the top of the diff switches between them, and every view is rendered against HEAD, so a line stays where it was on screen as you switch. Without that, checking your work would mean re-finding your place three times.