Manage IDEA Changelists for Bad Lines

2020-04-22

How do you handle not committing these bits and pieces the reviewers do not want to see?

Be it credentials or custom configuration for your local development environment: Not all changes you make to files should be committed.

Partial Commits

Staging resp. committing only parts of files is a useful feature of Git in that regard. On the command line, add the -p option when staging or committing. Good visual clients such as IDEA also support this.

Partial commit UI in IDEA

One problems remains, though: you have to repeat the exclusion for every commit.

Changelists

IDEA has this concept that seems almost redundant when using Git, but here it helps us. You can think of them as similar to Git stashes, but a bit more flexible. In this context, the important thing is that you can selectively exclude changes from commits, even if you commit changes in the same file.

Commit with changelists
Gutter UI

And this got me excited today: Whenever you click on the gutter stripe indicating a change, you can move that chunk to a separate changelist. This is way more robust than interactive commits: I can decide not to commit a change while working, and I can not forget later to exclude it.

Gutter UI to move change to changelist
ToolIntellij IDEAGit

Navigating Slack

Display Docker Space Usage