← Back to Git Course | Chapter 3: Branching | Lesson 9 of 9

GitHub Flow

GitHub Flow एक simple house rule है: एक main version रखें, हर नए idea के लिए एक छोटी side copy बनाएँ, और friends check करने के बाद इसे वापस merge करें।
Syntax
bash
git switch -c branch-name
git add file_name
git commit -m "message"
git push -u origin branch-name
# then open a pull request and merge into main

GitHub Flow क्या है

GitHub Flow एक single long-lived main branch और short-lived feature branches के आसपास बना एक lightweight branching model है -- GitFlow के कई permanent branches (develop, release, hotfix) के उलट, GitHub Flow deliberately continuously deploy करने वाली teams के लिए process overhead minimize करने के लिए सिर्फ एक permanent branch रखता है।

उदाहरण: What is GitHub Flow

bash
git checkout main
git checkout -b add-search

Main से Branch करना

काम का हर piece -- एक feature, एक fix, एक experiment -- को अपनी descriptively-named branch मिलती है जो सीधे main से cut होती है, पहले किसी intermediate develop branch से गुज़रे बिना।

उदाहरण: Branch From Main

bash
git checkout main
git checkout -b fix-header-bug

जल्दी एक Pull Request खोलना

GitHub Flow एक branch exist करते ही एक pull request खोलने को encourage करता है, काम पूरा होने से पहले भी -- PR feedback, CI results, और progress visibility के लिए एक चलती हुई conversation thread बन जाती है, सिर्फ एक final review gate नहीं।

उदाहरण: Open a Pull Request Early

bash
git push -u origin fix-header-bug
# open a pull request immediately, even before work is complete

Merge और Deploy करना

एक बार एक pull request review हो जाए और उसके checks pass हो जाएँ, इसे सीधे main में merge किया जाता है -- और क्योंकि इस model में main को हमेशा deployable माना जाता है, वह merge आमतौर पर तुरंत एक automatic या one-click production deployment के बाद आती है।

उदाहरण: Merge and Deploy

bash
git checkout main
git merge fix-header-bug
git push origin main

GitHub Flow बनाम GitFlow

GitHub Flow GitFlow की structured release/hotfix branches को simplicity के लिए trade करता है: sync में रखने के लिए कोई अलग develop branch नहीं, और कोई scheduled release branch नहीं -- main में हर merge एक potential deploy है, जो continuous delivery practice करने वाली teams को GitFlow के ज़्यादा deliberate, versioned release cadence से कहीं बेहतर suit करता है।

उदाहरण: GitHub Flow vs GitFlow

bash
git checkout -b feature-x main
# merges straight to main, no develop branch
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. पहले एक branch बनाने के बजाय सीधे main में commit करना, जो review bypass कर देता है।
  2. branches को vaguely fix या test जैसा नाम देना, जबकि add-search जैसे descriptive names purpose दिखाते हैं।
  3. एक branch को हफ्तों के लिए खुला छोड़ना, ताकि main आगे बढ़ जाए और merge मुश्किल हो जाए; branches short-lived रखें।
चैप्टर सारांश
  • Branches आपको development की अलग lines पर काम करने देते हैं, और आप उन्हें git branch, git checkout, और git switch से बनाते और बदलते हैं।
  • git merge, git rebase, और git cherry-pick changes को साथ लाते हैं।
  • Branch strategies और GitHub Flow describe करते हैं कि teams branches को कैसे organize करती हैं।

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.