Standard naming convention for commit messages
The standard naming convention for commit messages often follows the Conventional Commits specification. It helps to keep commit messages consistent and readable, especially when generating changelogs or tracking changes in a project.
Here are the common types of commit messages used in the Conventional Commits convention:
feat: A new feature or functionality.
- Example:
feat: add user authentication flow
- Example:
fix: A bug fix.
- Example:
fix: correct header alignment issue on mobile
- Example:
docs: Changes to documentation.
- Example:
docs: update README with installation instructions
- Example:
style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.).
- Example:
style: format code using prettier
- Example:
refactor: Code change that neither fixes a bug nor adds a feature (e.g., code cleanup or restructuring).
- Example:
refactor: restructure user service logic
- Example:
perf: Changes that improve performance.
- Example:
perf: improve database query performance
- Example:
test: Adding or updating tests.
- Example:
test: add unit tests for login component
- Example:
chore: Changes to the build process, tooling, or other non-functional updates (e.g., package updates).
- Example:
chore: update dependencies
- Example:
build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm).
- Example:
build: configure Webpack for production
- Example:
ci: Changes to Continuous Integration (CI) configuration files and scripts.
- Example:
ci: add Travis CI configuration
- revert: Revert a previous commit.
- Example:
revert: revert commit 12345abc
- fix! or feat!: Breaking changes in a fix or feature. The
!
indicates a breaking change.
- Example:
feat!: drop support for Node.js 8
- merge: For merging branches, though less commonly used if the merge commits are automatically created by Git.
- Example:
merge: merge feature branch into main
Structure of Commit Message:
<type>(<scope>): <short summary>
Type: What type of change it is (e.g.,
feat
,fix
,docs
).Scope: A module or file the commit is related to (optional, but can be useful for large projects).
Short Summary: Brief description of what was done (in imperative mood, e.g., "add feature", "fix bug").
Example Commit Messages:
feat(authentication): add JWT-based user authentication
fix(user-profile): resolve issue with profile picture upload
docs(api): update API usage documentation
refactor(utils): clean up redundant helper functions
This style helps maintain clean and clear commit history, making it easier for teams to understand what each commit achieves.