Advanced Git Workflows for Team Collaboration
The Problem with Long-Lived Branches
If your feature branches live for more than a few days, you're setting yourself up for merge conflicts, stale reviews, and integration headaches.
Trunk-Based Development
The solution is simple: everyone commits to main (or a single trunk branch) multiple times per day.
main ─── A ─── B ─── C ─── D ─── E
│ │
└─ fix ─────┘ (short-lived, < 1 day)Conventional Commits
Structure your commit messages for automated changelogs:
feat: add user authentication with OAuth 2.0
fix: resolve race condition in checkout flow
docs: update API reference for v3 endpoints
perf: optimize image loading with lazy hydrationTip
Use commitlint and husky to enforce conventional commits in your CI pipeline.
The Rebase vs Merge Verdict
Use rebase for feature branches, merge for integration:
# On your feature branch, rebase onto main# On main, merge the feature (creates a merge commit) git merge --no-ff feature/auth ```
This gives you clean, linear history on feature branches and clear merge points on main.
Automated Releases
Combine conventional commits with semantic-release:
# .github/workflows/release.yml
- uses: semantic-release/semantic-release
with:
branches: [main]Every push to main automatically: 1. Determines the version bump (major/minor/patch) 2. Generates the changelog 3. Creates a GitHub release 4. Publishes to npm
editor
Full-stack developer and open-source contributor. Writes about Node.js, databases, and system design. Core maintainer of several popular npm packages.
Comments (1)
We switched to trunk-based development 6 months ago and it's been transformative. No more week-long merge conflicts!
Related Posts
Mastering TypeScript Generics: Real-World Patterns
Move beyond basic generics with practical patterns for type-safe APIs, component props, and utility types that you'll use every day.
Optimizing React Performance: From 3s to 300ms
Real performance wins from a production React app — covering code splitting, memo strategies, virtualization, and the new React compiler.
Docker for Frontend Developers: A Gentle Introduction
You don't need to be a DevOps engineer to use Docker. Learn how containers can make your development workflow more reliable and portable.