|10. Advanced Git Commands
Chapter 10Git & GitHub~1 min read

Advanced Git Commands

Pro Level Git

Git चे काही advanced commands आहेत जे daily workflow मध्ये येतात आणि job interviews मध्ये विचारले जातात.

git rebase

Rebase — cleaner history

bash
# Feature branch ला main च्या latest commits वर "rebase" करा
git switch feature-login
git rebase main

# Interactive rebase — commits edit/squash करा
git rebase -i HEAD~3
# editor मध्ये:
# pick abc123 First commit
# squash def456 Second commit   (squash = previous मध्ये merge)
# pick ghi789 Third commit

git cherry-pick

Specific commit दुसऱ्या branch वर आणा

bash
# एखाद्या specific commit ला current branch वर apply करा
git cherry-pick abc1234

# Multiple commits
git cherry-pick abc1234 def5678

git bisect — Bug शोधा

Binary search for bug-introducing commit

bash
git bisect start
git bisect bad              # current commit buggy आहे
git bisect good v1.0        # v1.0 tag ठीक होतं

# Git automatically commits check करतो
# प्रत्येक commit वर test करा, good/bad सांगा
git bisect good
git bisect bad

# Bug-introducing commit सापडतो!
git bisect reset            # bisect संपवा

Tags — Releases

Version tags

bash
# Lightweight tag
git tag v1.0

# Annotated tag (better)
git tag -a v1.0 -m "Version 1.0 release"

# Tags push करा
git push origin --tags

# All tags बघा
git tag

Key Points — लक्षात ठेवा

  • git rebase — cleaner linear history
  • git cherry-pick — specific commit copy करा
  • git bisect — bug कोणत्या commit ने आला ते शोधा
  • git tag — releases mark करा
  • Rebase vs Merge: rebase cleaner, merge safer
0/10 chapters पूर्ण