Ravindra BagaleCourses & study guides Track your progress

Guides

नवशिक्यांसाठी 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 स्पष्ट वाटेल.

थोडक्यात उत्तर

हे पाच पॉइंट्स लक्षात ठेवा:

  1. Developers — प्रत्येकाला बदल संपवायला जागा हवी.
  2. Operations — server-side employee ज्याने stable main वरून deploy करावे, WIP नाही.
  3. Problem — दोघे main वर push; मिश्र history; review नाही.
  4. Branch + PR — side line → review → तयार झाल्यावर merge.
  5. लक्षात ठेवा: update main → branch → commit → push → open PR → merge.

Language: English · मराठी · हिंदी

Branching आणि PRs का हवे?

  1. Developers features संपवताना operations आज deploy करेल ते तोडू नये.
  2. Operations ला main releasable हवे.
  3. 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 फक्त review झालेले बदल स्वीकारतो. PR = काय बदलले, कोणी approve केले, काय test केले — त्यांच्या server आधी.

Git: working tree, staging, commit history Edit files in the working tree, git add to stage, git commit to save a snapshot. Commits form history on the branch. Working tree edit files README.md add Staging git add index commit Repository (.git) git commit · snapshots c1 c2 c3 main → History answers: which build is live? (no mystery zip) status → add → commit Then git push shares the same history with the team / operations

Git path: edit in the working tree, git add to stage, git commit to save a snapshot on the branch history.

Branch + PR त्याच fight ला कसे उत्तर देते

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

समजलं का? 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.