Advanced Git Workflows for Team Collaboration

MR
Marcus Rivera
·7 min read
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.

text
main ─── A ─── B ─── C ─── D ─── E
              │           │
              └─ fix ─────┘  (short-lived, < 1 day)

Conventional Commits

Structure your commit messages for automated changelogs:

text
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 hydration

Tip

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:

bash
# 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:

yaml
# .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

MR
Marcus Rivera

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)

MJ
Mike Johnson

We switched to trunk-based development 6 months ago and it's been transformative. No more week-long merge conflicts!

Related Posts

Optimizing React Performance: From 3s to 300ms
engineering9 min

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.

SC
Sarah Chen·
6,230