← Back to Git Course | Chapter 7: Collaboration | Lesson 2 of 6

Git Code Review

एक code review किसी friend से आपका essay turn in करने से पहले proofread करवाने जैसा है। आप exactly यह देखते हैं कि आप जहाँ से शुरू हुए उसकी तुलना में क्या बदला।
Syntax
bash
git diff base_branch...feature_branch
git log base_branch..feature_branch

Git Diff से Changes Compare करना

git diff <base>...<branch> exactly दिखाता है कि एक branch इसके fork होने की जगह के relative क्या बदलता है, जो ज़्यादातर code reviews का starting point है — यह वह actual content है जिसे एक reviewer को evaluate करना है, सिर्फ commit messages या file list के बजाय।

उदाहरण: Comparing Changes with Git Diff

bash
git diff main...feature-login

किसी Branch की Commit History देखना

git log <base>..<branch> सिर्फ उस branch की unique commits list करता है, एक reviewer को author की train of thought follow करने देते हुए — चाहे उन्होंने feature को focused commits के साथ incrementally बनाया हो या सब कुछ एक में dump कर दिया हो, जिस पर खुद अक्सर comment करने लायक होता है।

उदाहरण: Viewing Commit History of a Branch

bash
git log main..feature-login

एक Specific Commit Checkout करना

git checkout <commit> (आपको एक detached-HEAD state में लाते हुए) एक reviewer को actually code को branch की history में किसी भी point पर existed था वैसे चलाने देता है, PR में एक specific claim verify करने या change द्वारा fix होने वाले एक bug को reproduce करने के लिए उपयोगी।

उदाहरण: Checking Out a Specific Commit

bash
git checkout a1b2c3d

Git Blame से Authors ढूँढना

जब एक review को यह जानना हो कि (नई change खुद नहीं) मौजूदा code के किसी confusing हिस्से के बारे में किससे पूछना है, उस file पर git blame सीधे जिम्मेदार commit और author की ओर point करता है, review thread में एक round of "क्या किसी को पता है यह यहाँ क्यों है?" बचाते हुए।

उदाहरण: Finding Authors with Git Blame

bash
git blame file.txt

Commits Inspect करने के लिए Git Show इस्तेमाल करना

git show <commit> एक single commit की metadata और diff एक साथ एक view में दिखाता है, जो अक्सर एक पूरे multi-commit branch diff में scroll करने से एक focused commit review करने के लिए तेज़ है।

उदाहरण: Using Git Show to Inspect Commits

bash
git show a1b2c3d
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. git diff main..feature में दो dots इस्तेमाल करना जब आपको तीन चाहिए, main...feature, जो branch fork होने की जगह के against compare करता है।
  2. review के लिए एक commit checkout करना और detached-HEAD state में changes करना, जो आसानी से खो जाती हैं।
  3. सिर्फ final diff पढ़ना और git log main..feature skip करना, commit messages में reasoning miss करते हुए।
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.