Partial Staging of Git Changes in VS Code

A lot of developers, myself included, love to hate on Microsoft. And we have the odd good reason for doing so (cough, cough, Internet Explorer, cough). But they've been doing a lot of great stuff for non-Microsoft ecosystem developers too. My primary example of that is VS Code, their lightweight coding text editor that's an alternative to things like TextMate, Sublime, and Atom.

In particular, from day one, I've found VS Code's git integration to be pretty great. Amusingly enough, when I first tried Atom, I expected their git integration to be amazing, since it was coming from GitHub, which I also love. But nope, VS Code is the one thing that will pry my hands away from git on the command line in most cases.

The latest bit of functionality I've discovered is one that has always been a bit cumbersome on the command line... enough that depending on how adventurous I'm feeling that day, I might avoid it entirely: Partially staging changes.

Now git does have a pretty decent interactive shell thing with these that definitely makes it easier than with versioning tools I've used in the past. But I still would generally have to look up commands and think a little about what I'm actually doing with each keystroke. This is the sort of thing that really is made for a point and click UI.

Enter VS Code's way of doing it.

Say you've changed several lines in a file:

Gah! Don't commit desperate debugging statements!

...and you only want to commit the bottom two:

Just the good stuff!

Simply select that bottom portion in your code diff view and choose to Stage Selected Ranges:

Just select the whole range. Brilliant!

And like that, any actual changes within that selected block are staged.

This just feels so much more intuitive than the command line version, and makes it much more likely that I'll practice good git-ing by making smaller, more targetted commits, even when my development flow was a bit more scattered.

Of course, a post about Microsoft and developers wouldn't be complete without...

I'm sorry for not believing you at the time, Steve!!!