My Favorite Git Commit Message

It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters

My favorite commit message is just two words.

I use version control - Git, for the most part - 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. Something about using version control or source code management or whatever you want to call it makes my coding process smoother.

And I noticed something interesting, committing code into some repository or another almost every single day for the last several years. I have one commit message I use over and over and over. Click here

It's this: "code compress"

All lower case, just like that.

That's kind of a shorthand... I'll explain. Imagine I have code that's already working. Has unit tests, probably (though 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'm just testing manually.

So I've added the changes to the repo and committed already. It's committed in a (partially) working state.

Then, I make it better.

What do I do? I rename variables, functions and methods, so it's more readable (understandable) when myself or a teammate are modifying this 11 months later and don't remember what was in our heads back then. I take five or 20 or 100 lines of code, and I simplify it. So that it becomes two or seven or 35 lines. Whatever I can cut out.

No new features. Zero progress on functionality. I simply make the code more readable, maintainable, or otherwise better. It went from one working state, to another, equivalent working state. A completely horizontal move.

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

Often this makes the code base smaller, in terms of lines-of-code. In a way that (importantly) is more readable and maintainable. But still works just as well.

More elegant, in other words.

But not always. The actual change set doesn't *have* to reduce the lines of code. If I'm changing the names of identifiers, that has basically zero effect on the code size. Heck, I may take an obscure dozen lines and in the process of de-obfuscating it, now it's something like 80, or 200. So I'm not always actually compressing the code.

 




ema james

10 Blog Mensajes

Comentarios