Back to Blogs

[EN] Semantic Commit Message

GitGitHubCommit
Lazuardi Akbar Imani 2026-07-14
[EN] Semantic Commit Message

Semantic Commit Message

A complete guide to Semantic Commit Message — a convention for writing consistent, structured, and easy-to-understand commit messages.

© Dezkrazzer

📋 Table of Contents

Introduction

Semantic Commit Message is a convention for writing commit messages that follow a specific, structured format. This standard helps to:

  • Read commit history more easily
  • Automate versioning and changelog generation
  • Improve team collaboration
  • Keep change tracking structured and clear

Commit Format

The standard format for Semantic Commit Message is:

<type>(<scope>): <subject>

<body>

<footer>

Explanation:

PartDescription
typeThe kind of change (feat, fix, docs, etc.)
scopeThe part/module affected (optional)
subjectA short description of the change (imperative, lowercase)
bodyDetailed explanation of the change (optional)
footerAdditional info such as issue numbers (optional)

Example Format:

feat(authentication): add login feature with OAuth

Add OAuth 2.0 integration to improve security.
Users can sign in with Google or GitHub accounts.

Closes #123

Commit Types

TypeNameDescriptionExample
featFeatureAdds a new featurefeat: add login feature
fixBug FixFixes a bug or errorfix: fix crash when uploading large images
docsDocumentationChanges to documentation (README, Wiki)docs: update installation instructions in README
styleStyleCode style changes (formatting) without logic changesstyle: remove extra spaces in header
refactorRefactorCode restructuring without adding features or fixing bugsrefactor: simplify payroll calculation logic
perfPerformanceImprovements to performanceperf: optimize DB query for user list
testTestAdd or fix teststest: add unit tests for payment module
choreChoreSmall tasks, dependency updates, build scriptschore: update discord.js to v14
buildBuildChanges to build system (npm, gradle, gulp)build: add css minify script
ciCIChanges to CI configuration (GitHub Actions, Jenkins)ci: fix deploy script to vercel
revertRevertRevert a previous commitrevert: revert commit a2b3c4

Usage Examples

1. New Feature

feat(user-profile): add user profile page

- Adds a profile page showing user information
- Users can edit their profile picture
- Adds follow/unfollow functionality

Closes #45

2. Bug Fix

fix(checkout): fix error in payment form

Fixes an issue where the payment form did not submit when using Safari.
The bug was caused by an email validation incompatible with Safari.

Closes #89

3. Documentation Update

docs(README): update project setup instructions

- Add clear system requirements
- Improve confusing installation steps
- Add a troubleshooting section

4. Refactoring

refactor(auth): move authentication logic out of controller

Moved authentication logic from `UserController` to `AuthService` to
improve reusability and testability.

5. Performance Improvement

perf(database): use connection pooling for DB queries

Reduced response time from 200ms to 50ms by implementing connection
pooling in the database layer.

6. Testing

test(payment): add test cases for payment gateway

- Test successful payment
- Test failed payment
- Test timeout handling
- Test refund process

7. Dependency Changes

chore(dependencies): upgrade React from v17 to v18

- Update all React dependencies
- Fix breaking changes in components
- Update testing library versions

8. CI/CD Configuration

ci(github-actions): add workflow for automated testing

Adds a GitHub Actions workflow that:
- Runs linter on every pull request
- Runs unit tests automatically
- Generates coverage report

Best Practices

✅ Do

  • Use the imperative mood: "add" not "added" or "adding"
  • Do not capitalize the first letter of the subject: feat: add feature not feat: Add feature
  • Do not use a period at the end of the subject: feat: add feature not feat: add feature.
  • Separate subject from body with a blank line
  • Wrap body at 72 characters
  • Explain what and why, not how
  • Reference issues in the footer: Closes #123, Fixes #456
  • Make atomic commits: one logical change per commit

❌ Don't

# ❌ Bad - non-descriptive
git commit -m "update code"

# ❌ Bad - missing type
git commit -m "add login page"

# ❌ Bad - invalid type
git commit -m "add(feature): login page"

# ❌ Bad - too many changes in one commit
git commit -m "feat: add login, dashboard, and payment"

✅ Good

git commit -m "feat(auth): add login page with OAuth"
git commit -m "fix(checkout): fix email validation in payment form"
git commit -m "docs: update README with setup instructions"

Tools & Integration

Commitizen

Tool to help craft semantic commit messages:

npm install -g commitizen
npm install --save-dev cz-conventional-changelog

# Use it with
git cz

Husky + Commitlint

Automate commit message validation:

npm install husky commitlint --save-dev

npx husky install
npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'

File: commitlint.config.js

module.exports = {
	extends: ['@commitlint/config-conventional'],
};

Pre-commit Hook

Validate before committing:

npm install --save-dev @commitlint/cli

Git Aliases

Create aliases to simplify common commands:

git config --global alias.com 'commit -m'
git config --global alias.f 'fetch'
git config --global alias.p 'push'

Benefits

📊 Automated Changelog

With semantic commit messages, changelogs can be generated automatically:

## [1.2.0] - 2024-01-15

### Added
- feat: add login feature with OAuth
- feat(dashboard): add analytics widget

### Fixed
- fix: fix crash when uploading large images
- fix(checkout): fix email validation in payment form

### Changed
- refactor: simplify payroll calculation logic

🔄 Automated Versioning

Using Semantic Versioning (MAJOR.MINOR.PATCH):

  • MAJOR: for breaking changes
  • MINOR: for new backward-compatible features
  • PATCH: for bug fixes

🔍 Better Code Review

Reviewers can more easily understand the intent of changes from clear commit messages.

📝 Cleaner History

Commit history becomes more organized and easier to trace:

git log --oneline

🔄 Easier Bisecting

Finding the commit that introduced a bug is easier with consistent commit conventions.

References


Created to help teams understand and implement Semantic Commit Message effectively.