|4. Branches
Chapter 4Git & GitHub~1 min read

Branches

Parallel Development शिका

Branch म्हणजे तुमच्या project ची एक स्वतंत्र copy जी main code ला touch न करता नवीन features develop करण्यासाठी वापरतात. जेव्हा feature ready होतो तेव्हा main branch मध्ये merge करतात.

Marathi Analogy

Branch म्हणजे झाडाच्या फांद्या. Main trunk (main branch) हा stable code. नवीन feature साठी नवीन फांदी काढा — तिथे काम करा. Feature complete झाल्यावर फांदी परत trunk ला जोडा (merge). Trunk कधीही तुटत नाही!

Branch commands

bash
# सगळ्या branches बघा
git branch

# नवीन branch बनवा
git branch feature-login

# त्या branch वर जा (switch करा)
git checkout feature-login
# किंवा modern way:
git switch feature-login

# बनवा + switch एकत्र
git checkout -b feature-signup
# किंवा:
git switch -c feature-signup

# Branch delete करा
git branch -d feature-login

Typical feature branch workflow

bash
# main branch वर आहात
git switch main

# नवीन feature branch बनवा
git switch -c feature-dark-mode

# काम करा, commits करा
git add .
git commit -m "Add dark mode toggle"
git commit -m "Fix dark mode on mobile"

# main वर परत जा
git switch main
💡

नेहमी main/master branch वर directly commits करणे टाळा. प्रत्येक feature साठी वेगळी branch बनवणे professional practice आहे.

Key Points — लक्षात ठेवा

  • git branch — branches list करा
  • git switch -c name — नवीन branch बनवा
  • Default branch: main (किंवा master)
  • HEAD = तुम्ही सध्या कोणत्या branch/commit वर आहात
  • Branch delete: git branch -d name
0/10 chapters पूर्ण