| name | git-workflow |
| description | Git workflows, conventional commits, branching strategies, and PR management. Use for commits, branches, merges, rebases, and PR workflows. |
| allowed-tools | Bash, Read |
| user-invocable | true |
git-workflow
Git workflows, conventional commits, branching strategies, and pull request management.
Conventional Commits
Format: <type>(<scope>): <description>
Types
feat: New feature
fix: Bug fix
docs: Documentation only
style: Formatting, no code change
refactor: Code change, no feature/fix
perf: Performance improvement
test: Adding tests
chore: Build, config, dependencies
ci: CI/CD changes
revert: Revert previous commit
Examples
git commit -m "feat(auth): add OAuth2 login"
git commit -m "fix(api): handle null response"
git commit -m "docs: update README installation"
git commit -m "chore(deps): upgrade React to 19"
git commit -m "refactor(utils): simplify date formatting"
Breaking Changes
git commit -m "feat(api)!: change response format"
git commit -m "feat(api): change response format
BREAKING CHANGE: Response now returns array instead of object"
Branch Naming
Format
<type>/<ticket>-<description>
Examples
git checkout -b feat/AUTH-123-oauth-login
git checkout -b fix/BUG-456-null-pointer
git checkout -b chore/upgrade-dependencies
git checkout -b hotfix/security-patch
Types
feat/ Feature branch
fix/ Bug fix branch
hotfix/ Urgent production fix
chore/ Maintenance
docs/ Documentation
refactor/ Code refactoring
test/ Test additions
Common Workflows
Start New Feature
git checkout main
git pull origin main
git checkout -b feat/TICKET-123-feature-name
Commit Changes
git add -A
git commit -m "feat(scope): description"
Push and Create PR
git push -u origin HEAD
gh pr create --title "feat(scope): description" --body "## Summary\n- Change 1\n- Change 2"
Update Branch with Main
git fetch origin
git rebase origin/main
git merge origin/main
Interactive Rebase (squash commits)
git rebase -i HEAD~3
Amend Last Commit
git add .
git commit --amend --no-edit
git commit --amend -m "new message"
Undo Commits
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
Cherry Pick
git cherry-pick <commit-hash>
git cherry-pick <hash1> <hash2>
Stash Changes
git stash
git stash -m "description"
git stash list
git stash pop
git stash apply
git stash drop
Git Log
git log --oneline -10
git log --oneline --graph --all
git log --since="1 week ago"
git log --author="name"
git log --grep="fix"
git log -p
git log --stat
Git Diff
git diff
git diff --staged
git diff HEAD~3
git diff main..feature
git diff --name-only
Tags
git tag v1.0.0
git tag -a v1.0.0 -m "Release 1.0.0"
git push origin v1.0.0
git push origin --tags
git tag -d v1.0.0
git push origin :refs/tags/v1.0.0
Clean Up
git branch -d feature-branch
git branch -D feature-branch
git remote prune origin
git gc
Aliases (add to ~/.gitconfig)
[alias]
co = checkout
br = branch
ci = commit
st = status
lg = log --oneline --graph --all
last = log -1 HEAD
unstage = reset HEAD --
amend = commit --amend --no-edit
PR Best Practices
- Small PRs: Keep changes focused, < 400 lines
- Clear title: Use conventional commit format
- Description: Explain what and why
- Tests: Include relevant tests
- Self-review: Review your own diff first
- Screenshots: For UI changes
Merge Strategies
git merge feature-branch
git merge --squash feature-branch
git commit -m "feat: feature description"
git rebase main
git checkout main
git merge feature-branch --ff-only
Troubleshooting
Undo pushed commit
git revert <commit-hash>
git push
Fix detached HEAD
git checkout main
git checkout -b new-branch
Recover deleted branch
git reflog
git checkout -b recovered-branch <hash>
Resolve merge conflicts
git status
git add <resolved-files>
git commit