Using prefixes in git commit messages can improve the readability and categorization of your commits, especially when browsing the project history or generating changelogs. Here are some common prefixes that developers use to label their commit messages:
1. feat: Indicates a new feature for the user.
- Example:
feat: add search functionality to contacts page
2. fix: Indicates a bug fix.
- Example:
fix: resolve data loading issue on dashboard
3. docs: Documentation only changes.
- Example:
docs: update README with new installation instructions
4. style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc).
- Example:
style: format CSS according to style guide
5. refactor: A code change that neither fixes a bug nor adds a feature.
- Example:
refactor: simplify SQL query logic
6. perf: A code change that improves performance.
- Example:
perf: optimize image loading on homepage
7. test: Adding missing tests or correcting existing tests.
- Example:
test: add unit tests for user validation
8. chore: Regular code maintenance (upgrading dependencies, tooling changes).
- Example:
chore: update dependencies to latest versions
9. build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm).
- Example:
build: switch to yarn from npm
10. ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs).
- Example:
ci: add lint stage to CI pipeline
11. revert: Reverts a previous commit.
- Example:
revert: revert commit 1234567 where feature x was added
Using these prefixes helps in quickly identifying the purpose of a commit at a glance and can be very useful in managing large projects or when multiple contributors are involved. It’s also common to combine these prefixes with more detailed messages and scope (part of the software affected) to further clarify what and where changes were made.