Student Login

My favorite git commit message

My favorite commit message is just two words.

I use version control - Git, typically - all the time, even with little scripts no one will ever look at besides me, even when I probably don't need to.

I just like it. Makes my coding process smoother.

And I noticed something interesting, committing code into a repo almost every day for the last several years. I have one commit message I use over and over and over.

It's this: "code compress"

All lower case, just like that. It's kind of a shorthand.

Imagine I have code that's already working. Has unit tests, probably (maybe not enough of them... another topic). But it has unit tests which are passing, or maybe it doesn't, because the script is simple and I don't bother writing tests.

So I've added the changes to the repo and committed already. It's committed in a working state, at least the component or part I'm working on. All checked in.

Then, I make it better. What do I do?

I rename variables, functions and methods, so it's more readable. More understandable when I'm modifying it months later and have no clue what was in my head back then.

Or: I take five or 20 or 100 lines of code, and simplify it... make it 2 or 7 or 35 lines. Whatever I can cut out.

No new features. Zero progress on functionality. A completely horizontal move. I simply make the code more readable, maintainable, succinct. BETTER.

And the I git-add and git-commit. With the message "code compress".

After, the code does the exact same thing it did before. But I've made the code base smaller, more readable, maintainable.

More elegant.

This is great to do in your own private branch, where you can make a zillion tiny commits and no one will freak out about it. Sometimes I'll have three "code compress" commits in a row.

I do this so often, so frequently, that I just settled on the phrase "code compress" so I don't have to think about what message to write. There's probably a better name for it. But I can't be bothered to change that habit. The wording doesn't matter; the action does.

Get the idea?

What I realized is, this kind of tip, or wisdom, or whatever it is... It often doesn't make it into books or courses or even blog posts.

It's normally something you discover while writing larger applications. Like a lot of the important lessons, in writing software.

For Teams Bootcamp