Bisect: búsqueda de commits defectuosos
Use git bisect para realizar una búsqueda binaria en el historial y localizar el commit exacto que introdujo un error, incluso entre cientos de commits.
Bisect: búsqueda de commits defectuosos es una lección gratuita de Git Advanced: Monorepo, Submodules & Workflows en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Git Advanced: Monorepo, Submodules & Workflows, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Git Advanced: Monorepo, Submodules & Workflows incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
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.
Preguntas frecuentes
¿La lección «Bisect: búsqueda de commits defectuosos» es gratis?
Sí — el texto completo de «Bisect: búsqueda de commits defectuosos» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Git Advanced: Monorepo, Submodules & Workflows, actualiza a CoddyKit PRO. El curso de Git Advanced: Monorepo, Submodules & Workflows incluye 4 lecciones en total.
¿Qué aprenderé en «Bisect: búsqueda de commits defectuosos»?
Use git bisect para realizar una búsqueda binaria en el historial y localizar el commit exacto que introdujo un error, incluso entre cientos de commits. Practicas Git Advanced: Monorepo, Submodules & Workflows con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Git Advanced: Monorepo, Submodules & Workflows?
No se requiere experiencia previa. Git Advanced: Monorepo, Submodules & Workflows en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.
¿Cuánto tiempo toma la lección «Bisect: búsqueda de commits defectuosos»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Git Advanced: Monorepo, Submodules & Workflows?
Sí. Cada lección de Git Advanced: Monorepo, Submodules & Workflows incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Rebase interactivo y modificación de commits
- Stash y cherry-pick de cambios
- Reflog para recuperación
- Bisect: búsqueda de commits defectuosos