← Back to Git Course | Chapter 6: Advanced Commands | Lesson 4 of 7

Git bisect Command

git bisect एक guessing game जैसा है जहाँ आप हर day check करने के बजाय possibilities को बार-बार आधा करते रहते हैं यह ढूँढने के लिए कि exact day toy कब टूटा।
Syntax
bash
git bisect start
git bisect bad [commit]
git bisect good [commit]
git bisect reset

Git Bisect शुरू करना

git bisect commits को एक-एक करके check करने के बजाय binary search इस्तेमाल करके exact commit ढूँढता है जिसने एक bug introduce किया। आप इसे git bisect start से शुरू करते हैं, फिर search range define करने के लिए अपनी current commit को git bisect bad mark करते हैं और एक known-working पुरानी commit को git bisect good <hash>।

उदाहरण: Starting Git Bisect

bash
git bisect start
git bisect bad
git bisect good v1.0

Commits को Good और Bad Mark करना

range mark करने के बाद, Git good और bad के बीच वाली commit checkout करता है और इसे test करके git bisect good या git bisect bad से report करने का आपका wait करता है। हर answer बाकी बची range को आधा कर देता है, इसलिए एक हज़ार commits में छुपा एक bug आमतौर पर isolate होने में दस steps से कम लेता है।

उदाहरण: Marking Commits Good and Bad

bash
git bisect good
git bisect bad

Bisect Run के साथ Automate करना

एक automatable check वाले bug के लिए हर step पर manually test और report करना tedious है — git bisect run <script> Git को हर commit खुद test करने देता है, एक zero exit code को "good" और non-zero को "bad" मानते हुए, और यह unattended पूरा चलकर culprit commit report करेगा।

उदाहरण: Automating with Bisect Run

bash
git bisect run ./test.sh

Bisect Session Reset करना

git bisect reset session खत्म करता है और आपकी working directory को उस branch और commit पर वापस लाता है जिस पर आप शुरू करने से पहले थे — इस step को skip करना आपको bisect ने last में जो भी commit checkout किया था उस पर, एक detached-HEAD state में फँसा देता है।

उदाहरण: Resetting the Bisect Session

bash
git bisect reset

Bisect Log देखना

git bisect log session के दौरान किए आपके हर good/bad judgment को print करता है, और उसी output को दूसरी machine पर या नई commits pull करने के बाद same bisect फिर से चलाने के लिए git bisect replay में वापस feed किया जा सकता है — किसी teammate के साथ एक reproducible investigation share करने के लिए handy।

उदाहरण: Viewing Bisect Log

bash
git bisect log
git bisect replay bisect-log.txt
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. गलत commit को good या bad mark करना, ताकि bisect गलत commit की ओर point करे।
  2. बाद में git bisect reset भूल जाना और एक middle commit की detached-HEAD state में रह जाना।
  3. git bisect run को गलत exit codes return करने वाली एक script के साथ इस्तेमाल करना, जबकि 0 का मतलब good है और non-zero (1 से 127, 125 को छोड़कर) का मतलब bad।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 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.