Part 5: Advanced Version Control and Production Workflows

Introduction

The most stressful moment in my development career was when I had to deploy a hotfix to production at 2 AM because a critical payment processing bug was causing transaction failures. I learned that night that having solid production workflows and version control practices isn't just nice to have—it's essential for survival in production environments.

Since then, I've refined my approach to release management, hotfix procedures, and recovery strategies. In this final part of the series, I'll share advanced Git workflows, production best practices, and troubleshooting techniques I've learned from managing TypeScript microservices in production.

Release Management and Versioning

Semantic Versioning (SemVer)

I follow Semantic Versioning for all my projects: MAJOR.MINOR.PATCH

Example: 2.3.1

  • MAJOR (2): Incompatible API changes

  • MINOR (3): New features (backward compatible)

  • PATCH (1): Bug fixes (backward compatible)

Real-World Versioning Example

// Version 1.0.0 - Initial release
interface PaymentRequest {
  amount: number;
  currency: string;
}

// Version 1.1.0 - Added optional field (MINOR bump)
interface PaymentRequest {
  amount: number;
  currency: string;
  description?: string;  // New optional field - backward compatible
}

// Version 1.1.1 - Bug fix (PATCH bump)
// Fixed currency validation bug
// No interface changes

// Version 2.0.0 - Breaking change (MAJOR bump)
interface PaymentRequest {
  amount: number;
  currency: Currency;  // Changed from string to enum - BREAKING
  description?: string;
  metadata: Record<string, any>;  // New required field - BREAKING
}

Creating Releases on GitHub

Manual Release Process:

Automated Release with GitHub Actions:

To trigger release:

Hotfix Procedures

When Production is Broken

Scenario: Critical bug discovered in production—payment processing is failing.

Git Flow Hotfix Process:

GitHub Flow Hotfix (Simplified)

Emergency Deployment Checklist

I keep this checklist for production emergencies:

Git Hooks for Automation

Git hooks are scripts that run automatically at certain points in the Git workflow.

Pre-Commit Hook: Prevent Bad Commits

Using Husky for Git Hooks

Install Husky:

Create Pre-Commit Hook:

Commit Message Hook: Enforce Convention

Advanced Git Techniques

Interactive Rebase: Clean Up History

Scenario: Made messy commits while developing, want to clean up before PR.

Cherry-Pick: Apply Specific Commits

Scenario: Need to apply a specific fix from one branch to another.

Git Bisect: Find Bug Introduction

Scenario: Bug exists in production, but not sure when it was introduced.

Git Stash: Temporarily Save Work

Troubleshooting Common Issues

Issue 1: Accidentally Committed to Wrong Branch

Issue 2: Need to Undo a Pushed Commit

Issue 3: Merge Conflict Resolution

Issue 4: Large File Accidentally Committed

Issue 5: Recover Deleted Branch

Production Deployment Best Practices

Blue-Green Deployment with Git Tags

Deployment Freeze During Critical Periods

Monitoring After Deployment

Conclusion

Advanced version control workflows are essential for managing production systems reliably. Throughout this series, we've covered:

Part 1: Git fundamentals, essential commands, and basic workflows

Part 2: Branching strategies (Git Flow, GitHub Flow, Trunk-Based Development)

Part 3: Monorepo vs Polyrepo approaches with real examples

Part 4: GitHub collaboration, pull requests, and code reviews

Part 5: Release management, hotfix procedures, Git hooks, and troubleshooting

Key Lessons from Production Experience

  1. Always have a rollback plan before deploying

  2. Automate what you can (CI/CD, releases, checks)

  3. Use semantic versioning for clear communication

  4. Tag releases for easy rollback and tracking

  5. Monitor deployments for at least 30 minutes

  6. Document hotfix procedures before you need them

  7. Use Git hooks to prevent common mistakes

  8. Keep commit history clean for easier debugging

  9. Test thoroughly before production deployment

  10. Learn from incidents and improve processes

My Production Workflow Summary

Further Learning


Final Thoughts:

Version control is more than just a tool—it's a mindset. It's about:

  • Collaboration over individual work

  • Automation over manual processes

  • Safety over speed (though automation enables both)

  • Learning from every deployment

The best time to implement proper version control practices was at the start of your project. The second-best time is now.

Thank you for following this series! May your commits be atomic, your merges conflict-free, and your deployments successful! 🚀


Version Control 101 Series Complete

All parts:

  1. Introduction to Version Control and Git Fundamentals

  2. Branching Strategies and Workflows

  3. Monorepo vs Polyrepo Strategies

  4. GitHub Best Practices and Collaboration

  5. Advanced Version Control and Production Workflows

Remember: Good version control practices separate professional development from chaos!

Last updated