Git

Last Updated: 8/8/2023

Finding bugs using bisect

  • Using bisect command, you can quickly find the commit that introduce the issue
  • You tell git that current commit is bad or good

Starting bisect

git bisect start

Specify current commit is bad

git bisect bad

Find the last good commit

git log --oneline --all
git bisect good commitid
git bisect good
  • head is in the middle, git checked out the commit, working dir is restored to the point
  • You can run the app or automate test to see the issue is still there or not.
  • if the issue is there, the bug is introduced in the first half of history. specify the current commit as bad
  • if the issue doesn't exist, the issue is in the second half. specify the current commit as good
  • Using bisect, you can divide history in half, checkout various commit to find first bad commit

Attach head pointer to master branch

git bisect reset