DEV Community

Cover image for Git Conventional Commits:
Rajnish
Rajnish

Posted on

1

Git Conventional Commits:

What is Git Conventional Commits?

Git Conventional Commits is a structured way of writing commit messages that follow a specific format. It standardizes how developers describe changes, making version history more readable and automating processes like changelog generation and semantic versioning.

A conventional commit message follows this pattern:

type(scope): description
Enter fullscreen mode Exit fullscreen mode

For example:

feat(auth): add JWT authentication for secure login
fix(ui): resolve alignment issue in navbar
Enter fullscreen mode Exit fullscreen mode

Why is it Important?

  1. Improves Readability – Makes it easier to understand what changes were made and why.
  2. Enhances Collaboration – Team members can quickly scan commits without confusion.
  3. Automates Versioning – Helps in semantic versioning by identifying breaking changes, features, and fixes.
  4. Simplifies Release Notes – Changelogs can be auto-generated from commit messages.

How Does It Improve Our Standards?

  • Consistency – Following a uniform format ensures clean commit history.
  • Traceability – Each commit explains its purpose, helping in debugging.
  • Better CI/CD Integration – Tools like semantic-release and commitizen use structured commits for automation.

How Does It Make Us Stand Out?

Using conventional commits makes a developer look more professional and disciplined. Employers and team leads value clear documentation in commit history. It also facilitates better collaboration in open-source projects where clarity is crucial.

Real-Time Examples of Conventional Commits

1. Feature Addition

feat(button): add primary button component
- Created a reusable button component
- Supports different variants like primary and secondary
- Added unit tests for the button functionality
Enter fullscreen mode Exit fullscreen mode

2. Bug Fix

fix(login): resolve incorrect password validation
- Fixed regex issue causing false negatives
- Updated error message for better clarity
- Tested different edge cases
Enter fullscreen mode Exit fullscreen mode

3. Code Refactoring

refactor(auth): simplify login function
- Removed redundant API calls
- Consolidated validation logic
- Improved code readability without changing functionality
Enter fullscreen mode Exit fullscreen mode

4. Performance Improvement

perf(api): optimize user search query
- Added indexing to improve lookup speed
- Reduced query response time by 50%
- Implemented caching for frequently searched users
Enter fullscreen mode Exit fullscreen mode

5. Style Fixes

style(css): fix indentation in stylesheets
- Corrected inconsistent spacing
- Removed unused CSS classes
- Ensured all styles follow the project’s guidelines
Enter fullscreen mode Exit fullscreen mode

6. Adding or Modifying Tests

test(profile): add unit tests for profile updates
- Wrote test cases for edit profile functionality
- Covered edge cases for input validation
- Ensured all tests pass before merging
Enter fullscreen mode Exit fullscreen mode

7. Build System Update

build(dependencies): update React to v18
- Updated package.json and package-lock.json
- Resolved compatibility issues with third-party libraries
- Tested application for breaking changes
Enter fullscreen mode Exit fullscreen mode

8. CI/CD Configuration Change

ci(github-actions): add automated testing workflow
- Integrated Jest tests into GitHub Actions
- Set up automatic test execution on pull requests
- Configured Slack notifications for build failures
Enter fullscreen mode Exit fullscreen mode

9. Operational Changes

ops(deployment): automate database backups
- Implemented cron job for daily backups
- Stored encrypted backups in cloud storage
- Set up alert system for failed backups
Enter fullscreen mode Exit fullscreen mode

10. Documentation Update

docs(readme): update installation instructions
- Added steps for setting up the project locally
- Clarified database configuration requirements
- Included troubleshooting section
Enter fullscreen mode Exit fullscreen mode

11. Miscellaneous Changes

chore(gitignore): add .env to ignored files
- Prevented sensitive environment variables from being committed
- Updated .gitignore to include log files
- Cleaned up unnecessary files from the repository
Enter fullscreen mode Exit fullscreen mode

12. Merging Branches

merge(feature-branch): merge new feature into main
- Resolved conflicts in App.js
- Ensured all tests pass before merging
- Reviewed changes for consistency
Enter fullscreen mode Exit fullscreen mode

13. Reverting a Commit

revert(auth): rollback OAuth2 integration
- Encountered critical security issues with OAuth implementation
- Reverted changes and restored previous authentication method
- Documented findings for future improvements
Enter fullscreen mode Exit fullscreen mode

Conclusion

Adopting Git Conventional Commits improves code quality, collaboration, and automation. It ensures a well-maintained repository with clear commit history, making life easier for developers, reviewers, and CI/CD processes. By following this structured approach, we elevate our development standards and stand out as disciplined professionals in the industry.

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please show some love ❤️ or share a kind word in the comments if you found this useful!

Got it!