Pages

Thursday, 2 June 2016

Git Bisect


  1. Realize you have a defect in master.
  2. Find a changeset in the past where you know the defect didn't exist (make a note of it)
  3. checkout most recent changeset (i.e. master)
  4. git bisect start
  5. git bisect good [changeset]
  6. git bisect bad master
    1. This will set the checkout changeset to a bad state and checkout 
  7. Test your code
  8. If you find the bug
    1. git bisect bad
  9. If the bug doesn't exist
    1. git bisect good
  10. If you get to a changeset that prevents you from testing
    1. git bisect skip 
  11. When you get to the end, you should see something like:
00000e22334373dcddad1ggw48e3da8bfdce243b is the first bad commit
commit 00000e22334373dcddad1ggw48e3da8bfdce243b 

To exit from git bisect: git bisect reset
To go to that bad commit: git checkout 00000e22334373dcddad1ggw48e3da8bfdce243b