← Back to Git Course | Chapter 6: Advanced Commands | Lesson 3 of 7

Git Workflows (GitFlow)

GitFlow एक school schedule जैसा है जहाँ हर तरह की branch का अपना काम है, जैसे नए features बनाना, एक release तैयार करना और urgent bugs fix करना।
Syntax
bash
git checkout -b develop main
git checkout -b feature/feature_name develop
git checkout develop
git merge feature/feature_name

GitFlow Initialize करना

GitFlow एक branching model है जो हर branch type को एक specific role assign करता है — ongoing integration के लिए develop, नए काम के लिए feature/*, stabilization के लिए release/*, urgent production fixes के लिए hotfix/* — बजाय हर किसी के एक shared branch में commit करने के। यह scheduled releases वाले projects को suit करता है जहाँ आपको यह clear separation चाहिए कि क्या stable है और क्या progress में है।

उदाहरण: Initializing GitFlow

bash
git checkout -b develop main
git checkout -b feature/login develop

Features Develop करना

एक feature branch develop से cut होती है, isolation में बनती है, और खत्म होने पर वापस develop में merge होती है — लेकिन वह merge एक deliberate step है जिसे आप (या एक pull request) trigger करते हैं, GitFlow automatically नहीं करता। features को इस तरह isolated रखने का मतलब है कि एक unfinished feature कभी उस चीज़ को block या destabilize नहीं करती जिसे बाकी सब integrate कर रहे हैं।

उदाहरण: Developing Features

bash
git checkout -b feature/cart develop
git checkout develop
git merge feature/cart

Releases तैयार करना

एक release branch develop से एक बार fork होती है जब उसमें एक release के लिए काफी features हों, और सिर्फ last-mile काम के लिए इस्तेमाल होती है — bug fixes, version bumps, documentation — कभी नए features नहीं। ready होने पर, यह main (ship करने के लिए) और वापस develop (ताकि वे same fixes ongoing काम से न खो जाएँ) दोनों में merge होती है।

उदाहरण: Preparing Releases

bash
git checkout -b release/1.0 develop
git checkout main
git merge release/1.0
git checkout develop
git merge release/1.0

Hotfixes Execute करना

एक hotfix branch सीधे main से fork होती है ताकि यह develop पर इस समय चल रहे किसी भी काम का wait किए बिना एक live production bug patch कर सके। एक release branch की तरह, यह खत्म होने पर main और develop दोनों में merge होती है, यह ensure करते हुए कि fix तुरंत ship हो और अगले regular release से गलती से revert न हो।

उदाहरण: Executing Hotfixes

bash
git checkout -b hotfix/critical-bug main
git checkout main
git merge hotfix/critical-bug
git checkout develop
git merge hotfix/critical-bug

Features Publish करना

एक local feature branch को remote पर push करना (git push -u origin feature/x) एक private, local branch को कुछ ऐसे में बदल देता है जिसे teammates देख, checkout, और collaborate कर सकते हैं — आमतौर पर वह point जिस पर आप early feedback के लिए एक pull request भी खोलेंगे।

उदाहरण: Publishing Features

bash
git push -u origin feature/x
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. develop के बजाय main से एक feature branch करना, GitFlow structure तोड़ते हुए।
  2. एक release branch को सिर्फ main में merge करना और इसे वापस develop में merge करना भूल जाना।
  3. continuously release होने वाले एक छोटे project के लिए GitFlow इस्तेमाल करना, जो बिना किसी benefit के branches add करता है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.