How do I stage only part of a file?
Use the diff gutter: a hunk, a line, or a dragged block.
Select the file so its diff is on the right, then work in the gutter.
- A hunk — press Stage Hunk above the block of changes.
- A line — press its control in the gutter.
- A block of lines — drag down the gutter across them. They are applied as one step, not one operation per line.
The same actions are on the keyboard and in the context menu.
Once part of a file is staged and part is not, the All / Unstaged / Staged selector at the top of the diff switches between the three views without your place on screen moving.
If a hunk is bigger than you want, narrow the diff context — fewer unchanged lines between two changes can split one hunk into two.