name: git-workflow
description: Simplified gitflow workflow with conventional commits. Use when creating branches, committing code, merging changes, or managing git operations. Applies to feature and bugfix branches merging to main, with conventional commit message format (type(scope): description).
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:
git 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:
git 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
<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
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:
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
git checkout -b feature/user-profile
git checkout -b bugfix/navbar-overflow
Committing Changes
git add .
git commit -m "feat(auth): implement JWT token validation"
git commit --amend
Syncing with Main
git checkout main
git pull origin main
git checkout feature/your-branch
git rebase main
git add .
git rebase --continue
Pushing Changes
git push -u origin feature/your-branch
git push
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 --force when 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