Introduction

After exploring the power of git cherry-pick in our last post, it’s time to dive deeper into Git workflows that can make your development life smoother—especially if you’re building .NET applications in fast-moving teams or large codebases.

Whether you’re shipping features, fixing bugs, or managing hotfixes in production, the right Git strategy can save hours of merge headaches and deployment stress.

1. Feature Branch Workflow

The feature branch workflow is a staple in many teams using Git. It keeps the main (or master) branch clean and deployable at all times.

Steps:

# Create a new feature branch from main
git checkout -b feature/add-authentication main

# Work, commit changes
git add .
git commit -m "Add JWT-based authentication"

# Push the branch
git push origin feature/add-authentication

# Open a Pull Request (PR) for review and merging

This workflow works perfectly with tools like GitHub Actions or Azure DevOps for CI/CD pipelines.

.NET Tip: When starting a new microservice or module in a monorepo, use a feature branch to isolate your logic until it’s production-ready.


2. Git Rebase for a Clean History

Rebasing helps you keep a linear commit history, which is easier to understand and debug—especially during bisects or auditing.

Example:

# Rebase your feature branch onto the latest main
git checkout feature/add-authentication
git fetch origin
git rebase origin/main

Resolve any conflicts that come up. Then:

git push --force-with-lease

Why .NET developers should care: If you’re contributing to a shared library used across services, clean commits help trace issues and rollbacks with tools like GitVersion or GitHub Insights.


3. Git Stash for Context Switching

You’re halfway through coding, and suddenly you’re pulled into a production bug fix. Don’t lose your work in progress!

# Stash your uncommitted changes
git stash

# Switch to another branch to fix a bug
git checkout hotfix/urgent-logging-fix

# Later, return and restore your stashed work
git checkout feature/add-authentication
git stash pop

Use case: Great for .NET developers working across frontend (Blazor) and backend projects where switching branches and dependencies happens frequently.


4. Hotfix Workflow (Direct from Main)

Critical production bug? Use a hotfix branch, cherry-pick the fix, and deploy fast.

git checkout -b hotfix/fix-crash main
# Make your fix
git commit -am "Fix null ref crash on startup"
git push origin hotfix/fix-crash

Then either merge or cherry-pick into the feature and dev branches after production deployment.

Bonus: Tag the release.

git tag -a v1.2.1 -m "Hotfix release"
git push origin v1.2.1

5. Squash Merging for Simplicity

Squash merge turns a branch’s entire commit history into a single commit. Useful for clutter-free main history.

# From main branch
git merge --squash feature/add-authentication
git commit -m "Add JWT-based authentication"

.NET teams love this: When integrating with CI/CD pipelines that trigger on specific changes, a clean main branch helps trigger builds or deployments more predictably.


Summary

Git workflows are more than just commands—they’re habits that shape how we collaborate, deliver features, and maintain code quality.

Here’s a quick recap:

WorkflowBest For
Feature BranchParallel feature development
RebaseClean and linear commit history
StashQuick context switches
Hotfix BranchesEmergency production fixes
Squash MergeClean merges into main

For .NET developers, these workflows pair beautifully with tools like GitHub Actions, Azure DevOps, and .NET CLI automation.


Next Steps:
Try combining rebase and squash merges in your next PR to keep the history clean. Your future self (or team lead) will thank you!


Would you like me to convert this into Markdown format or help you prepare it for a specific platform (e.g., Dev.to, Medium, GitHub Pages)?

Powerful Git Workflows Every .NET Developer Should Know

Johannes Rest


.NET Architekt und Entwickler


Beitragsnavigation


Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert