Git Branching and Pull Requests for Beginners
Read this guide in: English · मराठी · हिंदी
Why do we need branches and pull requests? Because there is a real problem when developers all write on main, and operations on the server side gets half-finished work. Two people push different features to the same live line; users feel the break; nobody reviewed. A branch is a side line for one job. A pull request (PR) is the review table before merge — so the server-side person only sees work the team agreed on.
Friends, first see the “both edited main” crash. Then PR feels obvious.
Quick answer
Hold this vertical picture:
- Developers — each needs space to finish a change.
- Operations — server-side employee who should deploy from stable
main, not WIP. - The problem — both push to
main; mixed history; no review. - Branch + PR — side line → review → merge when ready.
- Pocket loop: update main → branch → commit → push → open PR → merge.
Language: English · मराठी · हिंदी
Why do we need branching and PRs?
- Developers need to finish features without breaking what operations might deploy today.
- Operations (server-side) needs
mainreleasable if the phone rings. - Review catches mistakes before the server sees them.
You need Git basics and a GitHub repo you own.
What does operations have to do with PRs?
- Operations deploys and watches health on the server side.
- If
mainis a junk drawer, every deploy is a gamble. - PRs protect
mainso both sides share one releasable line.
What is the problem? Suppose we are…
Suppose we are building Instagram (like updates)
Suppose one developer adds a profile badge on main while another rewrites the feed ranking on the same main. Both push. History mixes. Operations asks: which commit do I put on production?
Suppose we are working at Netflix and we are giving updates
Suppose two Netflix-style home-row fixes land unfinished on main the same afternoon. Millions of viewers can feel a bad merge. Review before merge is not optional at that scale.
Suppose you are working in Infosys on a client project
Suppose client operations only accepts changes that passed review. A PR is the paper trail: what changed, who approved, what was tested — before their server sees it.
Git path: edit in the working tree, git add to stage, git commit to save a snapshot on the branch history.
How branches and PRs answer that same fight
git checkout main
git pull
git checkout -b feature/profile-badge
# edit files …
git status
git add -A
git commit -m "Add profile badge field"
git push -u origin feature/profile-badge
Then on GitHub:
- Compare & pull request.
- Base:
main. Compare:feature/profile-badge. - Title + what changed / how you tested.
- Wait for CI if you have GitHub Actions.
- Address review comments with new commits on the same branch; merge; delete the branch.
- Locally:
git checkout main && git pull && git branch -d feature/profile-badge.
Ravindra Bagale's Tip
Huge “refactored the world” PRs scare reviewers — same as dumping twenty unfinished features on Infosys client ops at once. One purpose per branch. Lakshat theva.
What you should see
- PR shows commits and a green/red diff.
- After merge, GitHub
mainincludes your change. - Locally after
git pullonmain, log shows the merge or squash.
Common errors — story pain then fix
| Pain from the stories | Likely cause | Fix |
|---|---|---|
| PR has conflicts | Main moved since you branched | Update from main, fix, push |
| Pushed to main by mistake | Wrong branch checked out | Protect main; use branches |
branch is behind |
Forgot git pull on main |
Update main before new branches |
| Empty PR | No commits on the branch | Commit on feature branch, push |
| Cannot delete branch | Still checked out locally | git checkout main first |
Learn it properly
Samajla ka? Why branch/PR = stop half-finished work hitting the server-side person; Instagram / Netflix / Infosys “suppose”; side line → review → merge. One tiny PR tonight.
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.