Search code examples
gitvisual-studio-code

VS Code: How to stage and commit individual changes in a single file?


Visual Studio Code has excellent Git integration, but I can't find a way to partially stage changes like with git add --interactive or git add --patch. Basically, I want to be able to select specific changes in my files and stage them without staging the entire file. This functionality is supported by the Git CLI and GitHub native apps.

Mostly making sure I'm not just missing something before opening a ticket for it.


Solution

    • Open up the Source Control view, then click a changed file to open the comparison.

    • Select the lines you want to stage.

    • Click '...' then Stage Selected Ranges (in the ··· at the top-right corner of the editor, not the ··· at the top of the git panel on the left).

    enter image description here