| name | git-workflow |
| description | Git and GitHub workflow best practices. Use for commits, branches, PRs, merging, and version control operations. |
Git Workflow Skill
Git best practices for version control, branching strategies, and GitHub collaboration.
When to Use This Skill
- Creating commits with proper messages
- Managing branches
- Creating and reviewing pull requests
- Resolving merge conflicts
- Git history management
📝 Commit Messages
Conventional Commits Format
<type>(<scope>): <subject>
[optional body]
[optional footer(s)]
Commit Types
| Type | Description |
|---|
feat | New feature |
fix | Bug fix |
docs | Documentation only |
style | Formatting, no code change |
refactor | Code restructuring |
perf | Performance improvement |
test | Adding/updating tests |
chore | Maintenance tasks |
ci | CI/CD changes |
build | Build system changes |
Examples
feat(auth): add JWT token refresh mechanism
fix(proxy): resolve connection leak in upstream handler
feat(api): add rate limiting for /v1/chat endpoint
Implements token bucket algorithm with configurable
rate and burst size. Limits are per API key.
Closes
feat(config)!: change yaml config structure
BREAKING CHANGE: config.yaml format changed.
See migration guide in docs/migration-v2.md
🌳 Branching Strategy
Git Flow
main (production)
│
└── develop (integration)
│
├── feature/user-auth
├── feature/dashboard
├── fix/login-bug
└── release/v1.2.0
│
└── hotfix/critical-fix → main
Branch Naming
feature/add-user-authentication
feature/JIRA-123-dashboard-charts
fix/login-validation-error
fix/JIRA-456-memory-leak
release/v1.2.0
release/2024-01-sprint
hotfix/critical-security-patch
🔄 Pull Request Workflow
Creating a PR
git checkout -b feature/my-feature develop
git add .
git commit -m "feat: implement feature"
git push -u origin feature/my-feature
gh pr create --title "feat: implement feature" \
--body "Description of changes" \
--base develop
PR Template
## Summary
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Changes Made
- Change 1
- Change 2
## Testing
- [ ] Unit tests added/updated
- [ ] Integration tests pass
- [ ] Manual testing completed
## Screenshots (if UI changes)
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-reviewed
- [ ] Comments added for complex logic
- [ ] Documentation updated
Merging Strategies
gh pr merge --squash
gh pr merge --merge
gh pr merge --rebase
🔧 Common Git Operations
Stashing Changes
git stash save "WIP: feature description"
git stash list
git stash pop
git stash apply stash@{2}
git stash clear
Rebasing
git rebase -i HEAD~5
git rebase main
git rebase --continue
git rebase --abort
Cherry-picking
git cherry-pick abc123
git cherry-pick --no-commit abc123
git cherry-pick abc123..def456
Undoing Changes
git reset --soft HEAD~1
git reset --hard HEAD~1
git revert abc123
git checkout -- filename
git reset HEAD filename
🔀 Merge Conflict Resolution
Process
git fetch origin
git rebase origin/main
git add resolved-file.go
git rebase --continue
git push --force-with-lease
Conflict Markers
<<<<<<< HEAD
Your changes
=======
Their changes
>>>>>>> feature-branch
Tips
- Keep changes focused and PRs small
- Rebase frequently to avoid large conflicts
- Use
git mergetool for complex conflicts
- Communicate with team before force pushing
📊 Git History Management
Viewing History
git log --oneline --graph --all
git log -p -3
git log --grep="fix"
git log --author="name"
git log --stat
Finding Bugs with Bisect
git bisect start
git bisect bad
git bisect good v1.0.0
git bisect good
git bisect reset
🏷️ Tagging Releases
git tag -a v1.2.0 -m "Release version 1.2.0"
git push origin v1.2.0
git push --tags
git tag -l "v1.*"
git tag -d v1.2.0
git push origin --delete v1.2.0
📚 References