| name | git-workflow |
| description | Git workflow best practices and guidelines for efficient branch management, commits, and collaboration. |
| version | 1.0.0 |
| author | magic |
| license | MIT |
| metadata | {"hermes":{"tags":["git","workflow","collaboration","version-control"],"category":"software-development"}} |
Git Workflow Guide
A comprehensive guide for Git branch management, commit conventions, and collaborative development workflows.
When to Use
Load this skill when:
- Setting up a new repository or branch strategy
- Creating feature branches or bugfix branches
- Writing commit messages
- Opening or reviewing pull requests
- Dealing with merge conflicts
- Need to rebase, squash, or amend commits
Quick Reference
git checkout -b feat/add-login
git checkout -b fix/auth-bug
git checkout -b docs/update-readme
git checkout -b refactor/api-cleanup
git commit -m "feat: add user login endpoint"
git commit -m "fix: resolve authentication timeout"
git commit -m "docs: update API documentation"
git fetch origin
git rebase origin/main
git push origin feat/add-login
Branch Naming Convention
Follow the format: type/description
| Type | Usage |
|---|
feat/ | New features |
fix/ | Bug fixes |
docs/ | Documentation changes |
refactor/ | Code refactoring |
test/ | Adding or updating tests |
chore/ | Maintenance tasks |
perf/ | Performance improvements |
Rules:
- Use lowercase with hyphens:
feat/add-user-auth
- Keep descriptions concise but descriptive
- No spaces or special characters
Commit Message Format
Follow Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>
Examples
git commit -m "feat: add password reset endpoint"
git commit -m "fix(auth): resolve token expiration issue"
git commit -m "feat: implement user profile page
- Add profile display component
- Add edit profile functionality
- Integrate with user API"
git commit -m "feat: redesign API endpoints
BREAKING CHANGE: API endpoints now require authentication"
PR Process
- Create PR early - Use draft PRs to indicate work-in-progress
- Fill PR template - Provide context, testing steps, screenshots
- Request reviews - Tag appropriate team members
- Address feedback - Respond to comments, make requested changes
- Squash or rebase - Clean up commits before merging
- Delete branch - Clean up after merge
PR Title Format
feat: Add user authentication system
fix: Resolve login redirect loop
docs: Update deployment guide
Best Practices
Do's
- ✅ Write atomic commits (one logical change per commit)
- ✅ Write meaningful commit messages
- ✅ Keep branches focused on a single task
- ✅ Rebase before merging when appropriate
- ✅ Run tests before pushing
- ✅ Use
.gitignore properly
Don'ts
- ❌ Commit directly to
main/master
- ❌ Mix unrelated changes in one commit
- ❌ Force push to shared branches
- ❌ Leave large commented-out code blocks
- ❌ Commit sensitive data (API keys, passwords)
Common Workflows
Feature Development
git checkout main
git pull origin main
git checkout -b feat/new-feature
git add .
git commit -m "feat: implement new feature"
git fetch origin
git rebase origin/main
git push origin feat/new-feature
Hotfix
git checkout main
git pull origin main
git checkout -b fix/critical-bug
git add .
git commit -m "fix: resolve critical production bug"
git push origin fix/critical-bug
Pitfalls
Merge Conflicts
Problem: Conflicts when merging/rebasing
Solution:
- Pull/rebase frequently to minimize conflicts
- Communicate with team about overlapping changes
- Use
git status to identify conflicted files
- Edit files to resolve conflicts, then
git add and git commit
Forgetting to Pull
Problem: Local branch diverges significantly from remote
Solution:
- Always
git pull --rebase before starting new work
- Set up git alias:
git config --global alias.up 'pull --rebase'
Dangling Commits
Problem: Commits on detached HEAD or abandoned branches
Solution:
- Always create a branch for new work
- Use
git reflog to recover lost commits
Verification
After setting up workflow:
- Verify branch naming:
git branch shows proper names
- Check commit format:
git log --oneline shows conventional commits
- Confirm PR template: Create test PR to verify template appears
- Test rebase:
git rebase main completes without conflicts
Tools & References