Git Branch Strategies
In this page:
Git Flow Strategy
Git Flow parallel develop और main branches, plus dedicated feature/, release/, और hotfix/ branches के आसपास बना एक heavyweight, structured branching model है -- scheduled releases वाले projects के लिए well-suited, लेकिन अक्सर छोटी, fast-moving teams के लिए overkill।
उदाहरण: Git Flow Strategy
git checkout develop
git checkout -b feature/login
git checkout -b release/1.0 develop
git checkout -b hotfix/critical-bug main
GitHub Flow
GitHub Flow इसे एक rule तक strip कर देता है: जो भी आप काम कर रहे हैं उसके लिए main से branch करें, ready होने पर एक pull request खोलें, और review होते ही वापस main में merge करें -- उन teams के लिए काफी simple जो fixed schedule के बजाय continuously deploy करती हैं।
उदाहरण: GitHub Flow
git checkout main
git checkout -b add-search-bar
# open a pull request, review, then merge into main
GitLab Flow
GitLab Flow feature branches के साथ environment branches (जैसे staging और production) add करता है, ताकि code visibly हर environment से गुज़रे जैसे यह promote होता है -- आपको एक audit trail देते हुए कि exactly क्या कहाँ deployed है।
उदाहरण: GitLab Flow
git checkout -b staging main
git checkout -b production staging
Trunk-Based Development
Trunk-Based Development simplicity को और भी आगे push करता है: हर कोई एक shared trunk में frequently commit करता है, अक्सर एक दिन में कई बार, बहुत short-lived branches (या बिल्कुल भी नहीं) इस्तेमाल करते हुए specifically बड़े merge conflicts का दर्द कम करने के लिए।
उदाहरण: Trunk-Based Development
git checkout main
git checkout -b quick-fix
git commit -m "Small change"
git checkout main
git merge quick-fix
Stale Branches साफ करना
आप जो भी strategy follow करें, git branch --merged main को git branch -d के साथ combine करना उन feature branches साफ कर देता है जिनका काम पहले से main पर पहुँच चुका है, project बढ़ने के साथ branch list को clutter जमा होने से बचाते हुए।
उदाहरण: Cleaning Stale Branches
git branch --merged main
git branch -d old-feature
- अक्सर deploy होने वाले एक छोटे project के लिए Git Flow इस्तेमाल करना,
developऔर release branches add करते हुए जो सिर्फ team को धीमा करती हैं। - long-lived feature branches को
mainसे दूर drift होने देना, बड़े painful merges का कारण बनते हुए। - एक team के अंदर strategies mix करना, जैसे दूसरे feature branches इस्तेमाल करते हुए directly
mainमें commit करना।
Chapter Quiz — Complete all 9 topics to unlock
0/9 topics done
Complete these topics first: