πŸš€ Day 10: Git Branching

Sumith S RaikarSumith S Raikar
1 min read

What is Git Branching?

Git branching lets you work on new features or fixes without affecting your main code. It’s like creating a copy of your project where you can experiment safely.


Why Use Branches?

  • Keep main stable

  • Work on multiple features at once

  • Test ideas without risk

  • Collaborate easily


Common Branch Types

  1. main – Stable code

  2. feature/ – New features

  3. bugfix/ – Fixing issues

  4. hotfix/ – Quick production fixes


Essential Commands

bashCopyEditgit branch           # list branches  
git checkout -b new-feature   # create + switch  
git add .  
git commit -m "message"  
git checkout main  
git merge new-feature  
git branch -d new-feature    # delete branch

Quick Example

bashCopyEditgit checkout -b login-form
# Make changes
git add . && git commit -m "Add login form"
git checkout main
git merge login-form

Best Practices

  • Use clear names like feature/payment-page

  • Commit often

  • Delete branches after merging

  • Use pull requests in teams


Thank youu

0
Subscribe to my newsletter

Read articles from Sumith S Raikar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sumith S Raikar
Sumith S Raikar