Skip to content

Instantly share code, notes, and snippets.

@michaldabrowski
Created March 17, 2017 11:31
Show Gist options
  • Save michaldabrowski/3b2547c0eedf2b5b3865cf1b360f2f24 to your computer and use it in GitHub Desktop.
Save michaldabrowski/3b2547c0eedf2b5b3865cf1b360f2f24 to your computer and use it in GitHub Desktop.
git bisect

2017.03.17 git bisect

Binary search to find the commit that introduced a bug

Example

  • 97fb4a6 (HEAD -> git-bisect-test) (4 minutes ago) | Some change 123

(...)

  • 38620f0 (5 hours ago) | Some change 2
  • fbaf4f6 (5 hours ago) | Some change 1
  • 4a831ee (1 week ago) | Some feature 2
  • 09cb5c8 (1 week ago) | Some feature 1
  • 6c39822 (2 weeks ago) | [maven-release-plugin] prepare for next development iteration
  • 9a0257e (tag: app-1.0.0) (2 weeks ago) | [maven-release-plugin] prepare release app-1.0.0

Commit 97fb4a6 is broken (tests failed). We want to find out which commit introduced a bug.

  • Start bisect git bisect start

(git-bisect-test|BISECTING)

  • We know that current commit is BAD git bisect bad

  • We know that last release was OK git bisect good app-1.0.0

Bisecting: 103 revisions left to test after this (roughly 7 steps)[fbaf4f68f4ebeee50c84e38d228c59fa7d8e9ab3] some feature change

  • Run tests/scripts etc., if failed git bisect bad, if ok git bisect good

Bisecting: 51 revisions left to test after this (roughly 6 steps)

(...)

  • Result

97fb4a69ecca4ddc2c9837b7491c71d1c3a3797a is the first bad commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment