Bisect: البحث عن الالتزامات المعيبة
استخدم git bisect لإجراء بحث ثنائي عبر السجل وتحديد الالتزام الدقيق الذي أدخل خطأً، حتى عبر مئات الالتزامات.
Bisect: البحث عن الالتزامات المعيبة درس مجاني في Git Advanced: Monorepo, Submodules & Workflows على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Git Advanced: Monorepo, Submodules & Workflows، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Git Advanced: Monorepo, Submodules & Workflows 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Needle in the Haystack
A bug hides somewhere in your last 200 commits. git bisect runs a binary search through history, halving the suspect range with each test.
How Binary Search Helps
Checking 200 commits linearly means 200 tests. Binary search needs only about log2(200) ≈ 8 — bisect narrows the culprit dramatically faster.
Starting a Bisect
Kick off a session with git bisect start. From there Git walks you through marking commits as good or bad.
git bisect startMarking Good and Bad
Tell Git where the bug exists (bad) and an older commit where it didn't (good). That bounds the search range.
git bisect bad HEAD
git bisect good v1.2.0Testing Each Checkout
Git checks out the midpoint commit. You test it and report good or bad, and Git picks the next midpoint accordingly.
git bisect good
# or
git bisect badReaching the Culprit
After a few rounds, Git names the first bad commit — its hash, author, and message — the exact change that introduced the bug.
Ending the Session
Always finish with git bisect reset. It returns you to your starting branch and clears the bisect state.
git bisect resetAutomating with a Script
If you can test the bug programmatically, git bisect run ./test.sh automates the whole search — exit 0 means good, non-zero means bad.
git bisect run ./test.shThe Skip Escape Hatch
Hit a commit you can't test (it won't build)? git bisect skip tells Git to try a nearby commit instead.
git bisect skipReviewing the Log
git bisect log saves or replays the decisions you made — useful for documenting how you found a bug or resuming a session later.
git bisect logBest Practices
For reliable bisects: have a clear, reproducible test, keep commits small and atomic, and automate with git bisect run whenever you can.
Quick Check
Test your bisect knowledge.
Recap
Recap: git bisect start, mark good and bad, test each midpoint to halve the range, automate with run, skip the untestable, and reset when done.
الأسئلة الشائعة
هل درس «Bisect: البحث عن الالتزامات المعيبة» مجاني؟
نعم — نص درس «Bisect: البحث عن الالتزامات المعيبة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Git Advanced: Monorepo, Submodules & Workflows، انتقل إلى CoddyKit PRO. تتضمن دورة Git Advanced: Monorepo, Submodules & Workflows 4 دروس في المجموع.
ماذا ستتعلم في «Bisect: البحث عن الالتزامات المعيبة»؟
استخدم git bisect لإجراء بحث ثنائي عبر السجل وتحديد الالتزام الدقيق الذي أدخل خطأً، حتى عبر مئات الالتزامات. تتمرن على Git Advanced: Monorepo, Submodules & Workflows مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Git Advanced: Monorepo, Submodules & Workflows؟
لا تُشترط خبرة سابقة. Git Advanced: Monorepo, Submodules & Workflows على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «Bisect: البحث عن الالتزامات المعيبة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Git Advanced: Monorepo, Submodules & Workflows هذا؟
نعم. كل درس في Git Advanced: Monorepo, Submodules & Workflows يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- إعادة الأساس التفاعلية وتعديل الالتزامات
- تخزين التغييرات وانتقاؤها
- Reflog للاسترداد
- Bisect: البحث عن الالتزامات المعيبة