Skip to main content

How I Write Git Commit Messages: My Personal Convention

The commit message structure I adopted to keep my Git history consistent, readable, and meaningful.

Updated 7 min readMarkdown
How I Write Git Commit Messages: My Personal Convention

Introduction

When I work on a project, most of my attention goes to the code: building features, fixing bugs, testing endpoints. But how I record those changes in Git matters just as much, and it is the part I used to neglect.

It is tempting to commit with update, changes, or fixed stuff just to move on. Those messages make sense at the time, then become useless when I revisit a project weeks later. So I settled on a small convention that is consistent, simple, and descriptive enough that I can follow my own history without opening every commit.

Why I Care About Commit Messages

Git records what changed. The commit message records why. When I scan a project's history, I want to see at a glance whether I added a feature, fixed a bug, updated dependencies, or touched the docs.

Compare these:

Before

update files
changes
done

After

ft(orders): add order creation endpoint
fix(orders): allow order status updates
ch(dependencies): add project requirements
docs(readme): add project documentation

The difference is that the second set tells me what happened before I even open the commit.

For me, a good commit message isn't just a description of the files I changed. It should communicate the purpose of the change.

The Format I Use

I use the following structure which is inspired by Conventional Commits:

type(scope): description

Each part serves a purpose:

  • Type: Identifies the kind of change I made.
  • Scope: Identifies the area of the project affected.
  • Description: Briefly explains what I changed.

For example:

ft(orders): add order creation endpoint

Here, ft tells me that I added a feature, orders identifies the area of the application I worked on, and the description explains the actual change.

I keep the description short, write it in lowercase, and use the imperative mood. In other words, I write add order creation endpoint rather than added order creation endpoint. It keeps the message direct and consistent.

I also try to keep the first line around 50 characters, ideally within 50 to 72 characters, so it remains readable in the terminal and Git history.

My Commit Types

I don't use every possible commit type. I stick to the ones I find useful in my day-to-day workflow.

Prefix Meaning Example
ft Feature ft(meals): add meal creation endpoint
fix Bug fix fix(orders): allow order status updates
ch Chore ch(dependencies): add project requirements
docs Documentation docs(readme): add project documentation

ft for features

I use ft when I introduce new functionality to a project, such as adding an endpoint, implementing a search feature, or introducing a new capability.

ft(meals): add meal creation endpoint

fix for bug fixes

I use fix when correcting something that isn't working as expected or when changing existing behaviour to resolve a problem.

fix(orders): allow order status updates

ch for chores

I use ch for maintenance tasks that don't introduce application features or directly fix bugs. This could include adding dependencies, updating configuration, or general project maintenance.

ch(dependencies): add project requirements

docs for documentation

I use docs when updating documentation, writing setup instructions, documenting endpoints, or improving a project's README.

docs(readme): add project documentation

Why I Use Shortened Prefixes

My convention is inspired by Conventional Commits, but it isn't an exact implementation of the specification.

Conventional Commits uses prefixes such as feat for features and chore for maintenance. I shortened these to ft and ch because I prefer a compact format.

It's a personal preference, not a technical improvement. The shorter prefixes are easy for me to recognise and use, but they may be less obvious to someone unfamiliar with my commit history. They may also require additional configuration when working with tools that expect standard Conventional Commit types, such as commitlint or release automation.

If a project requires compatibility with those tools, I'd use the standard prefixes instead:

feat(orders): add order creation endpoint
chore(dependencies): add project requirements

For my personal projects, however, I prefer sticking with my shortened convention.

Why I Include a Scope

The scope is the part inside the parentheses. It identifies the area of the project affected by the commit.

For example:

ft(meals): add meal creation endpoint
ft(orders): add order creation endpoint
fix(orders): allow order status updates

The scope makes it easier to scan my commit history and understand which part of the application a change belongs to without opening the commit.

I don't force a scope into every message. When a change affects the entire project or doesn't belong to a specific module, I leave it out.

ch: update project configuration

The goal is to add context when it is useful, not to make every message unnecessarily complicated.

What About Refactoring, Tests, and Formatting?

Not every change fits neatly into the types I use regularly.

If I refactor existing code without changing functionality, I can use refactor. If I'm adding or updating tests, I can use test. For formatting or other maintenance work, I can use ch.

For example:

refactor(orders): simplify order validation
test(meals): add meal creation tests
ch(formatting): organize imports

I don't need to introduce a new prefix for every possible type of change. I just need the type to communicate what I did clearly.

My Rules for Writing Commit Messages

  1. Keep it lowercase: I prefer lowercase commit messages for consistency.
  2. Keep it concise: Describe the change without turning the commit message into a paragraph.
  3. Use a scope where appropriate: Identify the area affected when it adds useful context.
  4. Use the imperative mood: Write add, fix, or update, not added, fixed, or updated.
  5. Be specific: Avoid vague messages like update code, make changes, or final work.
  6. Keep commits focused: Commit related changes together instead of mixing unrelated tasks.
  7. Aim for a short first line: Keep it readable when viewing Git history.

These aren't strict rules enforced by Git. They are conventions I choose to follow to make my workflow more consistent.

Putting It Into Practice

Writing commit messages this way doesn't require any additional tools or complicated Git configuration. It's simply a habit I apply whenever I'm ready to commit a change.

For example, after adding a new endpoint to my FastAPI project:

git add main.py
git commit -m "ft(meals): add meal creation endpoint"
git push origin main

When updating documentation:

git add README.md
git commit -m "docs(readme): add project documentation"
git push origin main

And when fixing an issue with an existing endpoint:

git add main.py
git commit -m "fix(orders): allow order status updates"
git push origin main

The commands are the same as ever. Only the message changed.

Conclusion

Commit messages don't need to be complicated, only meaningful and consistent. This convention made me stop and ask what I did, where, and why before every commit. When I return to a project or review changes, I can read the history like a short changelog instead of decoding it.

About the author

Well Detailed

Thanks Muyiwa