gitpractice.dev

brewly — Ch.9 · Hunt a bug with bisect

Exercise 5 of 5

Before you start

Binary search through history

You know a version that worked and one that does not. git bisect checks out a commit halfway between them; you test it and say good or bad; it halves again. Nine commits take three or four tests.

Press "Run tests" to test whatever is checked out. Then tell git the result.

When it names the first bad commit, note its message, return with reset, and revert that commit.

git bisect start
begin
git bisect bad
the version checked out is broken
git bisect good <tag>
this version worked
git bisect good
the version checked out works
git bisect reset
go back to your branch
git log --oneline
find the commit again
git revert <commit>
undo it
You can reopen this any time with “Lesson”.

Continue on a desktop

Typing git on a small screen is no fun. Open this page on a laptop or desktop to practise.

Back to the path