,

Five reasons to write proper commit messages

We have all been there and probably done it ourselves.

An app randomly breaks or crashes, so you type “git log” to see what has changed recently.

And BOOM!

The history reads like:

  • 18:15: More updates.
  • 18:02: Updates.
  • 17:40: Updates.
  • 16:34: Fixed.
  • 12:22: Done.
  • 08:23: Complete.

And usually it’s not even punctuated correctly…

I can understand why. I have been guilty of this myself many times before.

When you’re rushing to get something done and you don’t commit frequently, it’s hard to even remember what you changed and why you changed it!

However, as usual, making shortcuts like this in the short term can be detrimental to the long game.

Here are five reasons to be disciplined by committing often and writing proper commit messages every time:

1) You understand better what you are doing.

Writing a proper git message helps re-enforce in your mind what you are working on.

I’ve had many epiphanies as a result of describing what I changed in my commit messages.

It helps you to be focused, as you are repeatedly bringing your mind back to the task at hand with every commit message you write.

2) It helps to break big tasks down into smaller ones.

In my last post I wrote about the benefits of breaking down tasks.

If you make too many changes in one commit then you will not be able to describe what you changed in a short, concise commit message.

Making frequent commits with detailed messages helps you to practice breaking big tasks down into smaller, more manageable chunks.

In the long term you’ll find that you get far more done as you break down the monster tasks into small chunks and chip away at it. Plus, if you ever have to go back and fix something – in the event of a crash or something breaking – you can troubleshoot so much faster.

3) Others can better understand what you changed.

Coding isn’t a single player game.

If you want to build amazing things you need to work well in teams.

A big part of working well in a team is communication.

Nothing helps developers communicate more than writing clear and concise commit messages in your code.

It means others can easily understand what you did at a glance and gives them less reason to distract you from what you are working on over questions about your code.

4) You can better understand what you changed.

Writing decent commit messages isn’t just about others understanding what you’re doing.

It’s also for you to understand what you’re doing.

How many times have you looked back at an application you worked on years ago and you can’t even remember working on that project at all?

Putting in decent commit messages will certainly help jog your memory and will help you to understand what you changed and why.

5) It is good practice for discipline.

The secret to being a great programmer is discipline.

Anyone can knock up a quick web app nowadays…

But few have the discipline to follow best practices to make it scalable and efficient.

Writing good commit messages is good practice to be disciplined in other areas of programming.

It also demonstrates to others that you have good discipline and you take pride in your work.

Thanks for reading. I’d love to hear your thoughts and experiences in the comments below.

Cheers,
Mark

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: