Git Workflows — Gitflow, Trunk-Based, GitHub Flow

Sanjeev SharmaSanjeev Sharma
2 min read

Advertisement

Git Workflows — Gitflow, Trunk-Based, GitHub Flow

Select a Git workflow matching your team's release and deployment patterns.

Gitflow

Best for scheduled releases:

main (production releases)
 └─ release/1.0
develop (development)
 ├─ feature/user-auth
 ├─ feature/dashboard
 └─ hotfix/bug-fix
# Feature development
git checkout -b feature/feature-name develop
git commit -m "feature: add feature"
git push origin feature/feature-name
# Create pull request to develop

# Release
git checkout -b release/1.0 develop
# Only bugfixes and version bumps
git checkout main && git merge release/1.0
git tag v1.0
git checkout develop && git merge release/1.0

# Hotfix
git checkout -b hotfix/bug-fix main
git commit -m "fix: urgent bug"
git checkout main && git merge hotfix/bug-fix
git tag v1.0.1
git checkout develop && git merge hotfix/bug-fix

Trunk-Based Development

Best for continuous deployment:

main (always deployable)
 ├─ feature/user-auth (short-lived)
 ├─ bugfix/critical-issue (short-lived)
 └─ (merge frequently)
# Create short-lived branch
git checkout -b feature/feature-name

# Minimal changes, frequent commits
git commit -m "feature: step 1"
git push

# Pull request and merge daily
git merge main

# Delete branch after merge
git branch -D feature/feature-name

GitHub Flow

Simplified for continuous deployment:

main (production)
 └─ feature/feature-name → PRMerge
# Simple flow
git checkout -b feature/feature-name
git commit -m "feature: add feature"
git push origin feature/feature-name
# Create PR, review, merge, deploy

FAQ

Q: Which workflow should I use? A: Trunk-based for fast iteration; Gitflow for scheduled releases; GitHub Flow as middle ground.

Advertisement

Sanjeev Sharma

Written by

Sanjeev Sharma

Full Stack Engineer · E-mopro