Bisect: individuare i commit problematici
Usi git bisect per eseguire una ricerca binaria nella cronologia e individuare il commit esatto che ha introdotto un bug, anche tra centinaia di commit.
Bisect: individuare i commit problematici è una lezione Git Advanced: Monorepo, Submodules & Workflows gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Git Advanced: Monorepo, Submodules & Workflows, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Git Advanced: Monorepo, Submodules & Workflows include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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.
Domande Frequenti
La lezione «Bisect: individuare i commit problematici» è gratuita?
Sì — il testo completo di «Bisect: individuare i commit problematici» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Git Advanced: Monorepo, Submodules & Workflows, passa a CoddyKit PRO. Il corso Git Advanced: Monorepo, Submodules & Workflows include 4 lezioni in totale.
Cosa imparerò in «Bisect: individuare i commit problematici»?
Usi git bisect per eseguire una ricerca binaria nella cronologia e individuare il commit esatto che ha introdotto un bug, anche tra centinaia di commit. Eserciti Git Advanced: Monorepo, Submodules & Workflows con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Git Advanced: Monorepo, Submodules & Workflows?
Non è richiesta alcuna esperienza precedente. Git Advanced: Monorepo, Submodules & Workflows su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Bisect: individuare i commit problematici»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Git Advanced: Monorepo, Submodules & Workflows?
Sì. Ogni lezione Git Advanced: Monorepo, Submodules & Workflows include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Rebase interattivo e modifica dei commit
- Stash e cherry-pick delle modifiche
- Reflog per il ripristino
- Bisect: individuare i commit problematici