A simple guide to help you understand and apply the Conventional Commit standard for versioning in your projects.
Adopting Conventional Commits improves your communication skills by encouraging clear and organized commit messages. It helps you focus on your changes and their impact, making it easier to manage projects and collaborate effectively.
When you make changes to your code and want to commit them using Conventional Commits, you'll use the git commit command in your terminal. The key is to follow the Conventional Commit format for your commit messages.
In your terminal, run the following:
git commit -m "feat(auth): add Google login feature"
-
Make Changes: Modify your files as needed.
-
Stage Your Changes: Add your modified files to the staging area. git add Or to add all changed files at once: git add .
-
Commit with Conventional Commit Message: After staging the changes, use the following command to commit: git commit -m "feat(button): add rounded corners"
-
Push the Changes: Push your commits to the remote repository. git push Or if you are pushing to a specific branch: git push origin
Each commit message follows this structure:
- type: Describes the change (e.g.,
feat,fix,chore) - scope: Optional. Refers to the area of the project being affected (e.g.,
api,frontend) - description: A short description of the change.
-
feat: A new feature for the user or system
Example:feat(auth): add Google login feature -
fix: A bug fix for the user or system
Example:fix(button): resolve issue with button hover state -
chore: Routine tasks like maintenance or updating dependencies
Example:chore(deps): update react to version 17.0.2 -
docs: Documentation updates
Example:docs(readme): update installation instructions -
style: Changes related to code style (e.g., formatting, missing semi-colons)
Example:style(button): fix button alignment in CSS -
refactor: Code change that neither fixes a bug nor adds a feature
Example:refactor(auth): simplify login form validation logic -
test: Adding or updating tests
Example:test(auth): add unit tests for login function -
build: Changes that affect the build system or external dependencies
Example:build(webpack): add webpack config for production build -
ci: Continuous integration-related changes
Example:ci(gitlab): update CI config for deployment pipeline -
perf: Code changes that improve performance Example:
perf(api): optimize database queries for faster responses -
env: Changes related to environment setup or configuration Example:
env(docker): update Dockerfile for staging environment -
sec: Security fixes or improvements Example:
sec(auth): add encryption for user passwords -
config: Changes to configuration files Example:
config: update .eslint rules for stricter code checks -
api: Updates to API contracts or integrations Example:
api(user): add new endpoint for user profile updates
revert: Reverts a previous commit
Example: revert(auth): rollback Google login feature
merge: Indicates a merge commit
Example: merge: branch 'feature/auth' into 'main'
deps: Dependency-specific updates
Example: deps: bump axios from 0.21.1 to 0.24.0
design: UI or UX improvements
Example: design(button): update hover effect
For a deeper understanding of Conventional Commits, check out the official documentation: Conventional Commits.
- Keep your messages clear and concise.
- Use the type that best represents the change you made.