Version Control
Rationale
Version control enables collaboration, tracks changes, and provides a safety net for code changes. It helps teams manage releases, rollbacks, and code reviews efficiently.
Git Workflow
Use Git for version control. Commit frequently and in small increments. Use pull requests for all merges.
- Commit frequently in small increments for easier review and rollback.
- Use feature branches for new work, bugfix branches for fixes, and release/hotfix branches for deployments.
- Use pull requests for all merges to main or develop.
Commit Messages
Commit messages should be clear, concise, and follow a convention:
- Use present tense: add, fix, update
- Keep under 50 characters if possible
- Format: type: short description
- Example: feat: implement user authentication
Good Examples:
- feat: add user registration
- fix: resolve login error
- docs: update API documentation Bad Examples:
- fixed stuff
- update
Type Prefixes
- feat: new features
- fix: bug fixes
- style: styling changes
- docs: documentation updates
- test: adding/updating tests
- refactor: code refactoring
- chore: miscellaneous tasks
Breaking Changes
If a commit introduces a breaking change, add BREAKING CHANGE: in the message.
Branching
Use descriptive and consistent branch names:
- Good: feature/user-authentication, bugfix/login-error, release/v1.0, hotfix/payment-issue
- Bad: feature, fix, release1
- Use prefixes: feature/, bugfix/, hotfix/, release/
- Avoid generic or ambiguous branch names.
Tagging and Versioning
Tag releases using Semantic Versioning: MAJOR.MINOR.PATCH (e.g., v1.0.0)
- Use annotated tags:
git tag -a v1.0.0 -m "Release v1.0.0" - Document release notes in CHANGELOG.md or release description.
Code Review
- Assign reviewers with relevant expertise.
- Address all review comments before merging.
- Use descriptive titles and summaries for pull requests.
- Link pull requests to related issues or tasks.
- Delete feature/bugfix branches after merging to keep the repository clean.
Best Practices
- Write descriptive commit messages
- Use pull requests for all merges
- Tag releases and maintain release notes
- Keep history clean by squashing and merging small commits.
- Review and update version control conventions as the team grows.