Git Workflow - Git Flow Pattern
Branch Structure
main - Production-ready code only. Tagged releases.
dev - Integration branch. All features merge here first.
feature/* - Individual features. Branch from dev, merge back to dev.
Common Operations
Start a New Feature
git checkout dev
git pull origin dev
git checkout -b feature/my-feature
Work on Feature
# Make changes
git add .
git commit -m "Descriptive message"
git push origin feature/my-feature # Optional: backup to remote
Complete Feature (Merge to Dev)
git checkout dev
git pull origin dev
git merge feature/my-feature
git push origin dev
Release to Production
# Only when dev is stable and ready for release
git checkout main
git pull origin main
git merge dev
git tag -a v0.x.x -m "Release version 0.x.x"
git push origin main --tags
Keep Dev in Sync with Main (Hotfixes)
# If hotfix was applied directly to main
git checkout dev
git merge main
git push origin dev
Rules
- Never commit directly to
main - only merge from dev
- All features start from
dev - not from main
- Test thoroughly on
dev before merging to main
- Tag all releases on
main with semantic versioning
- Delete feature branches after merging to keep repo clean