My Favorite Git Commit Message

My favourite commit message is simply two phrases.

I take advantage of model management – Git, for probably the most half – on a regular basis, even with little scripts nobody will ever have a look at in addition to me, even after I in all probability needn’t. I similar to it. One thing about utilizing model management or supply code administration or no matter you wish to name it makes my coding course of smoother.

And I seen one thing fascinating, committing code into some repository or one other nearly each single day for the final a number of years. I’ve one commit message I take advantage of again and again and over.

It is this: “code compress”

All decrease case, similar to that.

That is type of a shorthand… I will clarify. Think about I’ve code that is already working. Has unit checks, in all probability (although possibly not sufficient of them… one other subject). Nevertheless it has unit checks that are passing, or possibly it does not, as a result of the script is easy and I am simply testing manually.

So I’ve added the modifications to the repo and dedicated already. It is dedicated in a (partially) working state.

Then, I make it higher.

What do I do? I rename variables, features and strategies, so it is extra readable (comprehensible) when myself or a teammate are modifying this 11 months later and do not bear in mind what was in our heads again then. I take 5 or 20 or 100 traces of code, and I simplify it. In order that it turns into two or seven or 35 traces. No matter I can minimize out.

No new options. Zero progress on performance. I merely make the code extra readable, maintainable, or in any other case higher. It went from one working state, to a different, equal working state. A totally horizontal transfer.

After which I git-add and git-commit. With the message “code compress”.

Typically this makes the code base smaller, by way of lines-of-code. In a method that (importantly) is extra readable and maintainable. However nonetheless works simply as properly.

Extra elegant, in different phrases.

However not all the time. The precise change set does not *have* to cut back the traces of code. If I am altering the names of identifiers, that has mainly zero impact on the code measurement. Heck, I could take an obscure dozen traces and within the strategy of de-obfuscating it, now it is one thing like 80, or 200. So I am not all the time truly compressing the code.

However regardless, it is an enchancment.

That is nice to do in your individual personal department, the place you can also make a zillion tiny commits and nobody will provide you with a tough time about it. Typically I will have three “code compress” commits in a row.

I do that so typically, so ceaselessly, that I simply settled on the phrase “code compress” so I haven’t got to consider what message to jot down. There’s in all probability a greater identify for it. However I can not be bothered to alter that behavior. That takes willpower, and I’ve different habits which are extra necessary to alter.

However possibly you get the concept.

What’s nice about this idea:

Simply figuring out you should use “code compress” as a commit message,
routinely will get you excited about how one can frequently IMPROVE
your code.

Strive it at the moment. As a result of you’ll love the outcomes.

Leave a Comment