Skip to content

Instantly share code, notes, and snippets.

@myersg86
Forked from stevenyap/Git_Bisect.md
Created November 21, 2018 19:24
Show Gist options
  • Save myersg86/56138903bca7b52fd6af3b889b54a916 to your computer and use it in GitHub Desktop.
Save myersg86/56138903bca7b52fd6af3b889b54a916 to your computer and use it in GitHub Desktop.

Revisions

  1. @stevenyap stevenyap revised this gist Nov 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Git_Bisect.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    You have a git commit in your history that is causing a bug but you do not know which commit it is.
    You have a git commit in your history that is causing a bug but you do not know which commit it is.
    Here's how to use git bisect to find the commit that causes the bug.

    ```sh
  2. @stevenyap stevenyap revised this gist Nov 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Git_Bisect.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    You have a git commit in your history that is causing a bug but you do not know which commit it is.
    You have a git commit in your history that is causing a bug but you do not know which commit it is.
    Here's how to use git bisect to find the commit that causes the bug.

    ```sh
  3. @stevenyap stevenyap revised this gist Nov 17, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Git_Bisect.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    You have a git commit in your history that is causing a bug but you do not know which commit it is. Here's how to use git bisect to find the commit that causes the bug.
    You have a git commit in your history that is causing a bug but you do not know which commit it is.
    Here's how to use git bisect to find the commit that causes the bug.

    ```sh
    # in the git root, start the git bisect
  4. @stevenyap stevenyap revised this gist Nov 17, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Git_Bisect.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,11 @@ git bisect good
    git bisect bad

    # Repeat the above until git tells you which is the bad commit
    # eg. f5836a61c5e989b972499e5265760519580d3cfe is the first bad commit
    # Note down your bad commit hash

    # Upon finishing, then
    git bisect reset

    # Work on your bad commit!!!
    ```
  5. @stevenyap stevenyap created this gist Nov 17, 2014.
    28 changes: 28 additions & 0 deletions Git_Bisect.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    You have a git commit in your history that is causing a bug but you do not know which commit it is. Here's how to use git bisect to find the commit that causes the bug.

    ```sh
    # in the git root, start the git bisect
    git bisect start

    # mark current commit as bad
    git bisect bad

    # tell git which is the commit is good (it can be any good commit in the far history)
    git bisect good <commit-hash>

    # git will tell you roughly how many revisions you need to find the bad commit
    # eg. Bisecting: 24 revisions left to test after this (roughly 5 steps)
    # You are now at a commit that is chosen by git bisect
    # Run your test to determine if the commit is okay

    # if commit is okay, then
    git bisect good

    # if commit is bad, then
    git bisect bad

    # Repeat the above until git tells you which is the bad commit

    # Upon finishing, then
    git bisect reset
    ```