Cheatsheet Pages / Git Cheatsheet

How to find the commit that broke your code — git bisect

Something broke somewhere between the last release and now, and reading every commit would take days.

git bisect start
git bisect bad                    # current HEAD is broken
git bisect good v1.2.0            # v1.2.0 was fine
# git checks out commits; test each, then: git bisect good|bad
git bisect reset                  # done: back to where you started

Good to know

Bisect binary-searches history between a known-good and a known-bad commit.

Git Cheatsheet one-page card — 30 daily and rescue commands
The full one-page card — Git Cheatsheet. Get the complete cheatsheet on GitHub