How can I commit some changes to a file, but not others, in VSCode?
Solution 1:
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
.
Solution 2:
⚡ Summing up everything in this post with a gif.
- Make sure you're in the source control view to use this feature
- Select the range of code
- Open
···
at the top-right corner of the editor (not the···
at the top of the git panel on the left) - You can also press COMMAND (⌘) + K + COMMAND (⌘) + S to open keyboard shortcuts and search for
range
and then set a keyboard shortcut for this action.
Peace! ✌️