शुरुआती के लिए Git Branching और Pull Requests
Read this guide in: English · मराठी · हिंदी
Why branches और pull requests चाहिए? क्योंकि जब developers सब main पर लिखते हैं और operations (server side) को अधूरा काम मिलता है तब असली problem आता है। दो लोग अलग features एक ही live line पर push करते हैं; users को break महसूस होता है; review नहीं होता। Branch मतलब एक काम के लिए side line। Pull request (PR) मतलब merge से पहले review table — ताकि server-side person सिर्फ़ team‑सहमत काम देखे।
दोस्तों, पहले “दोनों ने main edit किया” crash देखो। फिर PR साफ़ लगेगा।
संक्षिप्त उत्तर
- Developers — हर एक को बदलाव खत्म करने की जगह चाहिए।
- Operations — server-side employee जो stable
mainसे deploy करे, WIP नहीं। - Problem — दोनों
mainपर push; मिली‑जुली history; review नहीं। - Branch + PR — side line → review → तैयार होने पर merge।
- Pocket loop: update main → branch → commit → push → open PR → merge।
Language: English · मराठी · हिंदी
Branching और PRs क्यों?
- Developers features खत्म करते समय operations आज जो deploy करेगा उसे न तोड़ें।
- Operations को
mainreleasable चाहिए। - Review server देखने से पहले गलतियाँ पकड़ता है।
Git basics और अपना GitHub repo चाहिए।
Problem? Suppose we are…
Suppose we are building Instagram (like updates)
एक developer main पर profile badge; दूसरा उसी main पर feed ranking। दोनों push। Operations पूछता है: production पर कौन‑सा commit?
Suppose we are working at Netflix and we are giving updates
दो Netflix-style home-row fixes अधूरे main पर। लाखों viewers को बुरा merge महसूस हो सकता है। Merge से पहले review optional नहीं।
Suppose you are working in Infosys on a client project
Client operations सिर्फ़ reviewed बदलाव स्वीकारता है। PR = क्या बदला, किसने approve किया, क्या test हुआ — उनके server से पहले।
Git path: edit in the working tree, git add to stage, git commit to save a snapshot on the branch history.
Branch + PR उसी लड़ाई का जवाब कैसे देता है
git checkout main
git pull
git checkout -b feature/profile-badge
git add -A
git commit -m "Add profile badge field"
git push -u origin feature/profile-badge
GitHub पर: Compare & pull request → base main → describe → CI (GitHub Actions) → merge → branch delete → git checkout main && git pull && git branch -d feature/profile-badge।
Ravindra Bagale's Tip
विशाल “सब refactor” PRs review थका देते हैं — Infosys client ops पर बीस अधूरे features डालने जैसा। एक branch पर एक उद्देश्य। याद रखो।
Common errors
| Pain | कारण | Fix |
|---|---|---|
| PR conflicts | Main आगे बढ़ गया | Main से update, fix, push |
| गलती से main पर push | गलत branch | Main protect करें; branches इस्तेमाल करें |
branch is behind |
Main pull भूले | नई branch से पहले main update |
| Empty PR | Branch पर commits नहीं | Feature branch पर commit, push |
| Branch delete नहीं होता | अभी checked out | पहले git checkout main |
Learn it properly
Samajla ka? Why branch/PR = अधूरा काम server-side तक न जाए; Instagram / Netflix / Infosys “suppose”; side line → review → merge। आज रात एक छोटी PR।
Frequently asked questions
What is a branch?
A branch is a movable line of commits so you can work without breaking main.
What is a pull request?
A PR asks to merge your branch into another branch after review.
Why not commit only on main?
Teams use branches so unfinished work stays isolated and reviews stay clear.
What is a merge conflict?
Two branches changed the same lines. Git asks you to pick the final text, then commit the fix.
Should I force-push?
Avoid force-push on shared branches. Prefer normal push after rebase only when your team agrees.
How long should a branch live?
Prefer short branches and small PRs — easier to review and safer to merge.