In the context of Git commits, these terms are often used as part of commit messages to provide a concise description of the changes made in a commit. Using a consistent structure for commit messages helps improve code collaboration and makes it easier to understand the purpose of each commit. The commonly used prefixes in commit messages are as follows:
feat: Short for "feature," this prefix is used when introducing a new feature or functionality to the codebase. For example:
feat: Add user authentication feature
chore: This prefix is used for commits related to maintenance tasks, build processes, or other non-user-facing changes. It typically includes tasks that don't directly impact the functionality but are necessary for the project's development and maintenance. For example:
chore: Update dependencies
chore: Refactor build script
fix: Used when addressing a bug or issue in the codebase. This prefix indicates that the commit contains a fix for a problem. For example:
fix: Correct calculation in revenue calculation
docs: Used when making changes to documentation, including comments in the code, README files, or any other documentation associated with the project. For example:
docs: Update API documentation
style: This prefix is used for code style changes, such as formatting, indentation, and whitespace adjustments. It's important to separate style changes from functional changes for better clarity. For example:
style: Format code according to style guide
refactor: Used when making changes to the codebase that do not introduce new features or fix issues but involve restructuring or optimizing existing code. For example:
refactor: Reorganize folder structure
test: Used when adding or modifying tests for the codebase, including unit tests, integration tests, and other forms of testing. For example:
test: Add unit tests for user authentication
perf: Short for "performance," this prefix is used when making changes aimed at improving the performance of the codebase. For example:
perf: Optimize database queries for faster response times
These prefixes help create a standardized way of categorizing and understanding the nature of the changes made in a commit. They contribute to better communication and collaboration among developers working on a project, making it easier to review and track changes over time.