| name | git-workflow-advanced |
| description | Advanced git workflows for teams - branching strategies (Git Flow, GitHub Flow, trunk-based), PR templates, commit conventions, conflict resolution, and release management. |
| tags | ["git","workflow","branching","pr","commits","collaboration","version-control"] |
| version | 1.0.0 |
| author | Enhanced from Git Flow + GitHub Flow + Trunk-Based Development) |
Git Workflow Advanced
Overview
Master advanced git workflows for professional team collaboration.
Key workflows:
- Git Flow - Feature branches, release branches, hotfixes
- GitHub Flow - Simple, deploy-focused workflow
- Trunk-Based Development - Short-lived branches, continuous integration
- Release Management - Versioning, changelogs, tags
Core principles:
- Main branch is always deployable
- Feature branches are short-lived (< 3 days)
- Commits are atomic and descriptive
- Pull requests are small and focused
- Code review is mandatory
When to Use
Git Flow:
- Scheduled releases (monthly, quarterly)
- Multiple versions in production
- Large teams (10+ developers)
- Enterprise software
GitHub Flow:
- Continuous deployment
- Small teams (2-10 developers)
- Web applications
- Fast iteration
Trunk-Based Development:
- Very frequent deployments (multiple per day)
- Mature CI/CD pipeline
- High-trust teams
- Feature flags for incomplete work
Git Flow Workflow
Branch Structure
main (production)
├── develop (integration)
│ ├── feature/user-auth
│ ├── feature/payment
│ └── feature/notifications
├── release/v1.2.0
└── hotfix/critical-bug
Branch Types
1. Main Branch
- Production-ready code
- Tagged with version numbers
- Never commit directly
- Only merge from release or hotfix
2. Develop Branch
- Integration branch
- Latest development changes
- Base for feature branches
- Merge features here first
3. Feature Branches
- New features or enhancements
- Branch from:
develop
- Merge to:
develop
- Naming:
feature/feature-name
4. Release Branches
- Prepare for production release
- Branch from:
develop
- Merge to:
main and develop
- Naming:
release/v1.2.0
5. Hotfix Branches
- Critical production fixes
- Branch from:
main
- Merge to:
main and develop
- Naming:
hotfix/critical-bug
Feature Branch Workflow
git checkout develop
git pull origin develop
git checkout -b feature/user-authentication
git add src/auth/
git commit -m "feat: add login endpoint"
git push origin feature/user-authentication
git checkout develop
git pull origin develop
git checkout feature/user-authentication
git merge develop
gh pr create --base develop --head feature/user-authentication \
--title "Add user authentication" \
--body "Implements login, signup, and password reset"
gh pr merge --squash
git branch -d feature/user-authentication
git push origin --delete feature/user-authentication
Release Branch Workflow
git checkout develop
git pull origin develop
git checkout -b release/v1.2.0
npm version minor
git add package.json package-lock.json
git commit -m "chore: bump version to 1.2.0"
git add CHANGELOG.md
git commit -m "docs: update changelog for v1.2.0"
git add src/bugfix.ts
git commit -m "fix: resolve login issue"
git checkout main
git pull origin main
git merge --no-ff release/v1.2.0
git tag -a v1.2.0 -m "Release version 1.2.0"
git push origin main --tags
git checkout develop
git merge --no-ff release/v1.2.0
git push origin develop
git branch -d release/v1.2.0
git push origin --delete release/v1.2.0
Hotfix Branch Workflow
git checkout main
git pull origin main
git checkout -b hotfix/critical-security-fix
git add src/security/
git commit -m "fix: patch SQL injection vulnerability"
npm version patch
git add package.json
git commit -m "chore: bump version to 1.2.1"
git checkout main
git merge --no-ff hotfix/critical-security-fix
git tag -a v1.2.1 -m "Hotfix: Security patch"
git push origin main --tags
git checkout develop
git merge --no-ff hotfix/critical-security-fix
git push origin develop
git branch -d hotfix/critical-security-fix
git push origin --delete hotfix/critical-security-fix
GitHub Flow Workflow
Simplified Structure
main (production)
├── feature/user-auth
├── feature/payment
└── fix/login-bug
Workflow Steps
git checkout main
git pull origin main
git checkout -b feature/user-authentication
git add .
git commit -m "feat: add login form"
git push origin feature/user-authentication
gh pr create --base main --head feature/user-authentication \
--title "Add user authentication" \
--body "WIP: Login form implemented, signup next"
git add .
git commit -m "feat: add signup form"
git push origin feature/user-authentication
gh pr ready
git add .
git commit -m "refactor: improve validation logic"
git push origin feature/user-authentication
gh pr merge --squash
git branch -d feature/user-authentication
Key Differences from Git Flow
Simpler:
- Only one long-lived branch (main)
- No develop branch
- No release branches
Faster:
- Deploy directly from main
- No waiting for release windows
- Hotfixes are just regular branches
Best for:
- Web applications
- Continuous deployment
- Small teams
Trunk-Based Development
Workflow
git checkout main
git pull origin main
git checkout -b add-login-button
git add src/components/LoginButton.tsx
git commit -m "feat: add login button component"
git push origin add-login-button
gh pr create --base main --head add-login-button
gh pr merge --squash
git branch -d add-login-button
git checkout main
git pull origin main
git checkout -b add-logout-button
Feature Flags for Incomplete Work
const ENABLE_NEW_AUTH = process.env.ENABLE_NEW_AUTH === 'true';
export function LoginPage() {
if (ENABLE_NEW_AUTH) {
return <NewAuthFlow />;
}
return <OldAuthFlow />;
}
Benefits
Faster integration:
- No long-lived branches
- No merge conflicts
- Continuous integration
Simpler workflow:
- One branch (main)
- No branch management overhead
- Easy to understand
Requirements:
- Strong CI/CD pipeline
- Comprehensive test coverage
- Feature flags for incomplete work
- High-trust team
Commit Conventions
Conventional Commits Format
<type>(<scope>): <subject>
<body>
<footer>
Types
feat: New feature
fix: Bug fix
docs: Documentation only
style: Formatting, missing semicolons, etc.
refactor: Code restructuring (no behavior change)
perf: Performance improvement
test: Add or update tests
build: Build system or dependencies
ci: CI/CD configuration
chore: Maintenance tasks
revert: Revert previous commit
Examples
Good commits:
git commit -m "feat(auth): add password reset functionality
Implements password reset via email link.
Users can request reset, receive email, and set new password.
Closes #123"
git commit -m "fix(api): resolve race condition in user creation
Added transaction to ensure atomic user creation.
Prevents duplicate users when multiple requests arrive simultaneously.
Fixes #456"
git commit -m "feat(api): change authentication to JWT
BREAKING CHANGE: Session-based auth is removed.
Clients must now use JWT tokens in Authorization header.
Migration guide: docs/migration-v2.md"
git commit -m "refactor(auth): extract validation logic
Moved validation from controller to separate module.
No behavior change, improves testability."
git commit -m "docs(readme): add installation instructions
Added step-by-step guide for local development setup."
Bad commits:
git commit -m "updates"
git commit -m "fix stuff"
git commit -m "WIP"
git commit -m "feat: add auth, fix bugs, update docs, refactor code"
git commit -m "fix"
git commit -m "changes"
Commit Message Template
cat > ~/.gitmessage << 'EOF'
EOF
git config --global commit.template ~/.gitmessage
Pull Request Best Practices
PR Template
<!-- .github/pull_request_template.md -->
## Description
<!-- What does this PR do? Why is it needed? -->
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
## How Has This Been Tested?
<!-- Describe the tests you ran -->
- [ ] Unit tests
- [ ] Integration tests
- [ ] Manual testing
## Checklist
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published
## Screenshots (if applicable)
<!-- Add screenshots to help explain your changes -->
## Related Issues
<!-- Link to related issues: Closes #123, Fixes #456 -->
PR Size Guidelines
Small PR (Ideal):
- 1-3 files changed
- < 200 lines added/removed
- Single focused change
- Easy to review (< 15 minutes)
Medium PR (Acceptable):
- 4-10 files changed
- 200-500 lines added/removed
- Related changes
- Reviewable in 30 minutes
Large PR (Avoid):
- 10+ files changed
- 500+ lines added/removed
- Multiple unrelated changes
- Hard to review (> 1 hour)
How to keep PRs small:
- Break features into smaller pieces
- Use feature flags for incomplete work
- Separate refactoring from features
- Submit documentation separately
PR Review Process
gh pr create --base main --head feature/user-auth \
--title "Add user authentication" \
--body "$(cat pr-description.md)"
gh pr edit --add-reviewer @teammate1,@teammate2
git add .
git commit -m "refactor: improve error handling per review"
git push origin feature/user-auth
gh pr review --approve
gh pr merge --squash --delete-branch
Conflict Resolution
Merge Conflicts
git checkout main
git pull origin main
git checkout feature/user-auth
git merge main
git add src/auth.ts
git commit -m "merge: resolve conflicts with main"
git push origin feature/user-auth
Rebase Conflicts
git checkout main
git pull origin main
git checkout feature/user-auth
git rebase main
git add src/auth.ts
git rebase --continue
git push origin feature/user-auth --force-with-lease
Merge vs Rebase
Use Merge when:
- Working on shared branches
- Want to preserve history
- Collaborating with others
Use Rebase when:
- Working on personal feature branches
- Want clean linear history
- Before creating PR
Never rebase:
- Public branches (main, develop)
- Shared feature branches
- After pushing to remote (unless alone on branch)
Release Management
Semantic Versioning
MAJOR.MINOR.PATCH
Example: 2.3.1
- MAJOR: 2 (breaking changes)
- MINOR: 3 (new features, backward compatible)
- PATCH: 1 (bug fixes, backward compatible)
When to bump:
- MAJOR: Breaking changes (API changes, removed features)
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Creating a Release
npm version minor
cat >> CHANGELOG.md << 'EOF'
- User authentication with JWT
- Password reset functionality
- Email verification
- Improved error messages
- Updated dependencies
- Login race condition
- Memory leak in session management
- Removed session-based auth (use JWT instead)
EOF
git add CHANGELOG.md package.json package-lock.json
git commit -m "chore: release v1.3.0"
git tag -a v1.3.0 -m "Release version 1.3.0"
git push origin main --tags
gh release create v1.3.0 \
--title "v1.3.0" \
--notes-file CHANGELOG.md \
--latest
npm publish
CHANGELOG.md Format
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Feature in progress
## [1.3.0] - 2026-05-26
### Added
- User authentication with JWT
- Password reset functionality
### Changed
- Improved error messages
### Fixed
- Login race condition
### Breaking Changes
- Removed session-based auth
## [1.2.0] - 2026-04-15
### Added
- User profiles
- Avatar upload
## [1.1.0] - 2026-03-01
### Added
- Initial release
Git Workflow Checklist
Before starting work:
During development:
Before creating PR:
During code review:
After merge:
Common Git Commands
Branch Management
git branch
git branch -r
git branch -a
git checkout -b feature/name
git branch feature/name
git checkout main
git switch main
git branch -d feature/name
git branch -D feature/name
git push origin --delete feature/name
git branch -m old-name new-name
Stashing Changes
git stash
git stash save "WIP: feature"
git stash list
git stash apply
git stash pop
git stash apply stash@{1}
git stash drop stash@{0}
git stash clear
Undoing Changes
git checkout -- file.ts
git checkout .
git reset HEAD file.ts
git reset HEAD .
git reset --soft HEAD~1
git reset --hard HEAD~1
git revert <commit-hash>
Viewing History
git log
git log --oneline
git log --graph --oneline
git log -n 5
git diff
git diff --staged
git diff main..feature/name
git log -- file.ts
git blame file.ts
Integration with Other Skills
Use before git workflow:
spec-driven-development-enhanced - Define what to build
incremental-implementation - Break into small commits
Use during git workflow:
tdd-iron-law - Test before committing
github-code-review - Review process
Use after git workflow:
github-pr-workflow - PR creation and management
Remember: Good git workflow is about communication. Commits tell a story, branches organize work, and PRs facilitate collaboration. Keep it simple, keep it clean, keep it consistent.