Git Conventions
Learn how Tuturuuu uses Conventional Commits and Branch naming to improve development workflow.
Prerequisite: You should be familiar with basic Git operations and understand the Monorepo Architecture of our codebase.
Overview
Tuturuuu follows standardized conventions for Git commits and branch naming to improve collaboration, automate releases, and maintain a clean, navigable repository history. We use two main specifications:
- Conventional Commits for structured commit messages
- Conventional Branch for consistent branch naming
These conventions help automate our CI/CD workflows, generate changelogs, and make our development process more efficient.
Conventional Commits
What are Conventional Commits?
Conventional Commits is a specification for adding human and machine-readable meaning to commit messages. It provides a set of rules for creating an explicit commit history, making it easier to write automated tools on top of.
The basic structure of a conventional commit is:
Types
Tuturuuu uses the following commit types:
Type | Description | Example |
---|---|---|
feat | New feature or enhancement | feat: add dark mode support |
fix | Bug fix | fix: prevent crash when user data is undefined |
docs | Documentation changes | docs: update installation instructions |
style | Code style changes (formatting, no code change) | style: format code with prettier |
refactor | Code refactoring | refactor: simplify authentication logic |
perf | Performance improvements | perf: optimize database queries |
test | Add or fix tests | test: add unit tests for auth middleware |
build | Changes affecting build system or dependencies | build: update dependency to fix security issue |
ci | Changes to CI configuration files and scripts | ci: add workflow for staging deployments |
chore | Routine tasks, maintenance | chore: update package.json metadata |
Scopes
Scopes provide additional context about which part of the codebase is affected. In our monorepo structure, we often use package or app names as scopes:
Breaking Changes
Breaking changes must be indicated by adding a !
after the type/scope or by using a BREAKING CHANGE:
footer:
Examples
Here are some examples of conventional commits used in our codebase:
Conventional Branches
What are Conventional Branches?
Conventional Branch refers to a structured naming convention for Git branches that makes it easier to identify branches by type and purpose.
The basic structure is:
Branch Types
Tuturuuu uses the following branch types:
Type | Description | Example |
---|---|---|
main | Main development branch | main |
feature | For new features | feature/user-dashboard |
bugfix | For bug fixes | bugfix/login-error |
hotfix | For urgent fixes | hotfix/security-vulnerability |
release | For preparing releases | release/v1.2.0 |
chore | For maintenance tasks | chore/update-dependencies |
Naming Rules
- Use lowercase alphanumeric characters and hyphens
- Keep names concise but descriptive
- Include ticket/issue numbers when applicable
- Avoid special characters (except hyphens)
Examples
How These Conventions Improve Our Workflow
1. Automated Changelog Generation
Our conventional commits are used to automatically generate changelogs for releases. Different commit types are categorized accordingly:
2. Semantic Versioning
Conventional commits help determine the next semantic version for packages:
fix:
commits trigger a PATCH increment (1.0.0 → 1.0.1)feat:
commits trigger a MINOR increment (1.0.0 → 1.1.0)- Commits with
BREAKING CHANGE
trigger a MAJOR increment (1.0.0 → 2.0.0)
3. Automated Package Publishing
In our CI workflows, package publishing is automatically triggered when a PR with specific commit types is merged. For example, our release-types-package.yaml
workflow triggers when:
4. Better Code Reviews
With conventional commits and branches, it’s easier to understand the purpose of a pull request at a glance:
- A PR from
feature/user-dashboard
with commits likefeat: add user stats widget
clearly indicates a new feature - A PR from
bugfix/auth-issue
with commits likefix: prevent token expiration error
indicates a bug fix
5. Simplifying Navigation
Conventional branch names make it easier to navigate the repository history and find specific changes. For example:
Tools and Enforcement
We use a dedicated CI/CD check to enforce our Git conventions:
Branch Naming Check
We use a GitHub Action workflow to verify that branch names follow our convention:
Best Practices
Writing Good Commit Messages
- Use the imperative mood (“add” not “added” or “adds”)
- Capitalize the first letter of the description
- Do not end the description with a period
- Keep the description under 72 characters
- Use the body to explain the what and why, not the how
Example of a well-formatted commit:
Branch Management
- Create branches from the latest
main
branch - Keep branches focused on a single task or issue
- Regularly rebase long-lived branches on
main
to avoid merge conflicts - Delete branches after they’ve been merged
Pull Request Workflow
- Create a branch with the appropriate type based on the work
- Make commits using conventional commit messages
- Push the branch and create a pull request
- Use conventional commit style for the PR title
- After approval and merge, delete the branch
Conclusion
Following these Git conventions helps us maintain a clean, understandable repository history, automate release processes, and improve collaboration across the team. By standardizing both commit messages and branch names, we create a more efficient development workflow.
For more information, refer to the official documentation for Conventional Commits and Conventional Branch.