Juri Strumpflohner


Partial Commits in WebStorm

Author profile pic
Juri Strumpflohner

I think partial commits should be avoided as they might lead to inconsistent commits if you don’t test them properly. But sometimes they’re handy too. In this article I’m quickly showing how partial commits can be done in Webstorm.

When interacting with Git, the command line is my goto place. I have a couple of aliases set up and installed git-extras. That makes it a pretty powerful workflow.

Btw, I have an Egghead course that teaches the minimum set of Git commands a dev should know to be productive.

Why partial commits?

Generally, I think they should be avoided. Sometimes though, if you have lots of changes, even covering different responsibilities, it might be worthwile to split them up. That’s when partial commits come in handy. They allow you to only add certain lines of a file into the commit, rather than the entire file.

Enable partial commits in Webstorm

Webstorm has a commit dialog which is handy for inspecting the changes. If you open up the dialog you see something like this:

The dialog shows you the differences, but there’s no way to just include some of the lines. To configure that you have to enable the “Highlight modified lines in gutter” option.

This should open the Webstorm preferences dialog. Make sure you have the setting enabled there:

Once that’s done, re-open the commit dialog. You should now be able to click the gutter and add single lines.