Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
Git Version Control & Collaboration 14 mins read Free Lesson

Branching Strategies & Fast-Forward Merging

Create branches with git branch and git switch, merge features, and prevent long-lived branch divergence.

Branching in Git

Branches in Git are lightweight, movable pointers to commits:

# Create and switch to a new feature branch
git switch -c feature/payment-gateway

# Switch back to main branch
git switch main

# Merge feature into main
git merge feature/payment-gateway

# Delete feature branch after merge
git branch -d feature/payment-gateway