Git Workflow
This skill defines the git workflow using conventional commits and a simplified gitflow approach.
Branch Strategy
Branch Types
main - Production-ready code. All features and bugfixes merge here.
feature/ - New features and enhancements
- •Naming:
feature/<short-description>(e.g.,feature/user-authentication) - •Created from:
main - •Merges to:
main
bugfix/ - Bug fixes
- •Naming:
bugfix/<short-description>(e.g.,bugfix/login-error) - •Created from:
main - •Merges to:
main
Branch Workflow
- •
Start new work:
bashgit checkout main git pull origin main git checkout -b feature/your-feature-name
- •
During development:
- •Commit frequently using conventional commit messages
- •Keep branches focused on a single feature or fix
- •Rebase on main regularly to stay current
- •
Before merging:
bashgit checkout main git pull origin main git checkout feature/your-feature-name git rebase main
- •
Merge to main:
- •Create pull request
- •After approval, merge to main
- •Delete feature/bugfix branch after merge
Conventional Commits
All commits must follow the Conventional Commits specification.
Format
code
<type>(<scope>): <description> [optional body] [optional footer(s)]
Types
- •feat: New feature
- •fix: Bug fix
- •docs: Documentation changes
- •style: Code style changes (formatting, missing semicolons, etc.)
- •refactor: Code refactoring without changing functionality
- •perf: Performance improvements
- •test: Adding or updating tests
- •build: Build system or dependency changes
- •ci: CI/CD configuration changes
- •chore: Other changes that don't modify src or test files
Scope
Optional. Indicates the area of the codebase affected (e.g., auth, api, ui, database).
Examples
bash
feat(auth): add login functionality fix(api): resolve null pointer exception in user endpoint docs(readme): update installation instructions refactor(utils): simplify date formatting logic test(auth): add unit tests for password validation
Breaking Changes
For breaking changes, add ! after the type/scope or add BREAKING CHANGE: in the footer:
bash
feat(api)!: change response format to JSON API spec BREAKING CHANGE: The API now returns responses in JSON API format instead of the previous custom format. Update client code accordingly.
Git Commands Reference
Creating Branches
bash
# Feature branch git checkout -b feature/user-profile # Bugfix branch git checkout -b bugfix/navbar-overflow
Committing Changes
bash
# Stage changes git add . # Commit with conventional message git commit -m "feat(auth): implement JWT token validation" # Amend last commit git commit --amend
Syncing with Main
bash
# Update your branch with latest main git checkout main git pull origin main git checkout feature/your-branch git rebase main # If conflicts occur, resolve them then: git add . git rebase --continue
Pushing Changes
bash
# First push of new branch git push -u origin feature/your-branch # Subsequent pushes git push # After rebase (force push required) git push --force-with-lease
Best Practices
- •Commit frequently - Small, focused commits are easier to review and revert
- •Write clear commit messages - Follow conventional commits format consistently
- •Keep branches short-lived - Merge feature branches within a few days
- •Rebase before merging - Keep history clean by rebasing on main before creating PR
- •Delete merged branches - Clean up branches after they're merged to main
- •Use
--force-with-lease- Safer than--forcewhen pushing after rebase - •One feature per branch - Don't mix unrelated changes in the same branch
Pull Request Guidelines
- •Clear title - Use conventional commit format for PR title
- •Description - Explain what changed and why
- •Link issues - Reference related issues (e.g., "Closes #123")
- •Small PRs - Easier to review, faster to merge
- •Review before merge - At least one approval required
- •Squash option - Consider squashing commits if the branch has many small commits
When to Use This Skill
This skill should be used when:
- •Creating new branches for features or bugfixes
- •Making commits (to ensure proper conventional commit format)
- •Preparing to merge code to main
- •Managing git operations within this project
- •Reviewing or creating pull requests