Skill v1.0.1
currentAutomated scan100/1001 files
metadata: version: "1.0.1"
name: git-workflow-designer description: Expert guide for designing Git branching strategies including Git Flow, GitHub Flow, trunk-based development, and release management. Use when establishing team workflows or improving version control practices. slug: git-workflow-designer category: operations complexity: complex version: "1.0.0" author: "id8Labs" triggers:
- "git-workflow-designer"
- "git workflow designer"
tags:
- development
- tool-factory-retrofitted---
Git Workflow Designer Skill
Core Workflows
Workflow 1: Primary Action
- Analyze the input and context
- Validate prerequisites are met
- Execute the core operation
- Verify the output meets expectations
- Report results
Overview
This skill helps you design and implement effective Git branching strategies for teams of any size. Covers Git Flow, GitHub Flow, trunk-based development, release management, and branch protection policies.
Workflow Selection Philosophy
Key Factors
- Team size: Solo vs. small team vs. large organization
- Release frequency: Continuous vs. scheduled releases
- Environment complexity: Single vs. multiple deployment targets
- Risk tolerance: Move fast vs. stability first
Workflow Comparison
| Workflow | Best For | Release Frequency | Complexity | |
|---|---|---|---|---|
| Trunk-Based | Small teams, CI/CD | Continuous | Low | |
| GitHub Flow | Most web apps | On-demand | Low | |
| Git Flow | Versioned software | Scheduled | High | |
| GitLab Flow | Environment-based | Mixed | Medium |
GitHub Flow (Recommended for Most)
Overview
Simple, effective workflow for continuous deployment.
main ─────●─────●─────●─────●─────●─────●\ / \ /feature/x ●─────● ●─────●
Process
- Branch from main
``bash git checkout main git pull origin main git checkout -b feature/user-authentication ``
- Commit regularly
``bash git add . git commit -m "feat: add login form component" ``
- Push and create PR
``bash git push -u origin feature/user-authentication gh pr create --title "Add user authentication" --body "..." ``
- Review and merge
- CI runs tests
- Peer review
- Squash merge to main
- Deploy
- Automatic deploy on merge to main
Branch Naming Convention
feature/ - New featuresfix/ - Bug fixesdocs/ - Documentationrefactor/ - Code refactoringtest/ - Test additionschore/ - Maintenance tasks
Configuration
# .github/branch-protection.yml (pseudo-config)main:required_status_checks:strict: truecontexts:- "ci/tests"- "ci/lint"- "ci/build"required_pull_request_reviews:required_approving_review_count: 1dismiss_stale_reviews: trueenforce_admins: falserestrictions: null
Git Flow (For Versioned Releases)
Overview
Structured workflow for scheduled release cycles.
main ─────●─────────────────●─────────────●\ / \release ●─────●─────●─ ●───\ \ / /develop ●─────●─●─────●─●─────●─────●─────●─●\ / \ / \ /feature ●─● ●─────● ●─────●
Branches
| Branch | Purpose | Merges To | |
|---|---|---|---|
main | Production-ready code | - | |
develop | Integration branch | main | |
feature/* | New features | develop | |
release/* | Release preparation | main, develop | |
hotfix/* | Emergency fixes | main, develop |
Feature Development
# Start featuregit checkout developgit pull origin developgit checkout -b feature/new-dashboard# Work on featuregit commit -m "feat: add dashboard layout"git commit -m "feat: add dashboard charts"# Complete featuregit checkout developgit merge --no-ff feature/new-dashboardgit branch -d feature/new-dashboardgit push origin develop
Release Process
# Start releasegit checkout developgit checkout -b release/1.2.0# Bump versionnpm version 1.2.0 --no-git-tag-versiongit commit -am "chore: bump version to 1.2.0"# Fix release issuesgit commit -m "fix: correct typo in release notes"# Complete releasegit checkout maingit merge --no-ff release/1.2.0git tag -a v1.2.0 -m "Release 1.2.0"git push origin main --tagsgit checkout developgit merge --no-ff release/1.2.0git push origin developgit branch -d release/1.2.0
Hotfix Process
# Start hotfixgit checkout maingit checkout -b hotfix/1.2.1# Fix the issuegit commit -m "fix: critical security vulnerability"# Complete hotfixgit checkout maingit merge --no-ff hotfix/1.2.1git tag -a v1.2.1 -m "Hotfix 1.2.1"git push origin main --tagsgit checkout developgit merge --no-ff hotfix/1.2.1git push origin developgit branch -d hotfix/1.2.1
Trunk-Based Development
Overview
Everyone commits to main with short-lived branches.
main ─●─●─●─●─●─●─●─●─●─●─●─●─●─●─●─●\─/ \─/ \─/PR PR PR
Principles
- Short-lived branches (< 1 day)
- Small, frequent commits
- Feature flags for incomplete work
- Comprehensive CI/CD
Feature Flags Integration
// src/lib/features.tsexport const features = {newCheckout: process.env.FEATURE_NEW_CHECKOUT === 'true',darkMode: process.env.FEATURE_DARK_MODE === 'true',};// Usageif (features.newCheckout) {return <NewCheckout />;}return <OldCheckout />;
Branch Rules
# Quick feature (< 4 hours)git checkout maingit pullgit checkout -b quick/fix-typo# ... work ...git push -u origin quick/fix-typogh pr create --title "Fix typo" --body ""# Merge immediately after CI passes
Release Management
Semantic Versioning
MAJOR.MINOR.PATCH1.0.0 - Initial release1.1.0 - New feature (backwards compatible)1.1.1 - Bug fix2.0.0 - Breaking change
Automated Version Bumping
// package.json{"scripts": {"release:patch": "npm version patch && git push --follow-tags","release:minor": "npm version minor && git push --follow-tags","release:major": "npm version major && git push --follow-tags"}}
Changelog Generation
# .github/workflows/release.ymlname: Releaseon:push:tags:- 'v*'jobs:release:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4with:fetch-depth: 0- name: Generate changelogid: changeloguses: metcalfc/changelog-generator@v4with:myToken: ${{ secrets.GITHUB_TOKEN }}- name: Create Releaseuses: actions/create-release@v1env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}with:tag_name: ${{ github.ref }}release_name: Release ${{ github.ref }}body: ${{ steps.changelog.outputs.changelog }}
Conventional Commits
# Format<type>(<scope>): <description>[optional body][optional footer(s)]# Typesfeat: New featurefix: Bug fixdocs: Documentationstyle: Formatting, no code changerefactor: Refactoringtest: Testschore: Maintenance# Examplesfeat(auth): add password reset flowfix(api): handle null user gracefullydocs: update README with new API endpointschore(deps): update dependencies
Commitlint Configuration
// commitlint.config.jsmodule.exports = {extends: ['@commitlint/config-conventional'],rules: {'type-enum': [2,'always',['feat','fix','docs','style','refactor','test','chore','perf','ci','build','revert',],],'subject-case': [2, 'always', 'lower-case'],'header-max-length': [2, 'always', 72],},};
Branch Protection
GitHub Branch Protection Rules
# Recommended settings for main branchRequired status checks:- ci/test- ci/lint- ci/build- ci/typecheckRequired reviews: 1Dismiss stale reviews: trueRequire review from code owners: trueRequire signed commits: false # OptionalRequire linear history: true # Encourages squash/rebaseInclude administrators: false # Allow admins to bypassRestrict who can push:- Maintainers only
CODEOWNERS
# .github/CODEOWNERS# Default owners* @team-lead# Frontend/src/components/ @frontend-team/src/app/ @frontend-team# Backend/src/api/ @backend-team/src/lib/db/ @backend-team# Infrastructure/.github/ @devops-team/docker/ @devops-team# Docs/docs/ @tech-writer*.md @tech-writer
Merge Strategies
Squash and Merge (Recommended)
# Clean history, one commit per featuregit merge --squash feature/branchgit commit -m "feat: complete feature description"
Pros:
- Clean main history
- Easy to revert features
- Commit message can be edited
Cons:
- Loses individual commit history
Rebase and Merge
# Linear history, preserves commitsgit rebase main feature/branchgit checkout maingit merge feature/branch
Pros:
- Linear history
- Preserves individual commits
- Bisect-friendly
Cons:
- Requires clean commits
- Force push may be needed
Merge Commit
# Preserves full history with merge pointsgit merge --no-ff feature/branch
Pros:
- Complete history preserved
- Clear merge points
- No force push needed
Cons:
- Noisy history
- Harder to navigate
Common Scenarios
Sync Feature Branch with Main
# Option 1: Rebase (clean history)git checkout feature/my-featuregit fetch origingit rebase origin/maingit push --force-with-lease# Option 2: Merge (safe, but noisy)git checkout feature/my-featuregit merge origin/maingit push
Undo Last Commit (Not Pushed)
# Keep changes stagedgit reset --soft HEAD~1# Keep changes unstagedgit reset HEAD~1# Discard changesgit reset --hard HEAD~1
Fix Commit Message
# Last commit onlygit commit --amend -m "new message"# Older commits (interactive rebase)git rebase -i HEAD~3# Change 'pick' to 'reword' for target commit
Cherry-Pick Specific Commit
# Apply specific commit to current branchgit cherry-pick abc123# Cherry-pick without committinggit cherry-pick --no-commit abc123
Recover Deleted Branch
# Find the commitgit reflog# Recreate branchgit checkout -b recovered-branch abc123
Workflow Scripts
Git Aliases
# ~/.gitconfig[alias]# Statuss = status -sb# Branchingco = checkoutcob = checkout -bbr = branch -vv# Commitscm = commit -mca = commit --amend --no-edit# Logginglg = log --oneline --graph --decorate -20lga = log --oneline --graph --decorate --all -20# Syncsync = !git fetch origin && git rebase origin/main# Cleanupcleanup = !git branch --merged | grep -v main | xargs git branch -d# Undoundo = reset --soft HEAD~1
Feature Branch Script
#!/bin/bash# scripts/feature.shset -eBRANCH_TYPE=${1:-feature}BRANCH_NAME=$2if [ -z "$BRANCH_NAME" ]; thenecho "Usage: ./scripts/feature.sh [type] <name>"echo "Types: feature, fix, docs, chore"exit 1fiFULL_BRANCH="$BRANCH_TYPE/$BRANCH_NAME"echo "Creating branch: $FULL_BRANCH"git checkout maingit pull origin maingit checkout -b "$FULL_BRANCH"echo "Branch '$FULL_BRANCH' created and checked out"echo "Run: git push -u origin $FULL_BRANCH"
Workflow Checklist
Before Selecting Workflow
- [ ] Understand team size and distribution
- [ ] Define release frequency
- [ ] Assess CI/CD maturity
- [ ] Consider deployment environments
Implementation
- [ ] Document workflow in CONTRIBUTING.md
- [ ] Configure branch protection rules
- [ ] Set up CODEOWNERS
- [ ] Configure merge strategy
- [ ] Add commit message linting
- [ ] Create Git aliases/scripts
Maintenance
- [ ] Regular branch cleanup
- [ ] Monitor merge queue
- [ ] Review and update protection rules
- [ ] Train new team members
When to Use This Skill
Invoke this skill when:
- Starting a new project and choosing a workflow
- Scaling from solo to team development
- Improving release management
- Setting up branch protection rules
- Creating contribution guidelines
- Resolving Git workflow conflicts
- Implementing conventional commits