Skip to content

Instantly share code, notes, and snippets.

@krisanalfa
Created December 18, 2014 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisanalfa/37ab4bdec50f98b33a71 to your computer and use it in GitHub Desktop.
Save krisanalfa/37ab4bdec50f98b33a71 to your computer and use it in GitHub Desktop.
Tutorial git-bisect
krisanalfatimur@supernova ~/Temp/test (git)-[master] % git log --oneline
c470042 [ADD] New method to determine the number of cigarrete.
6ab57ea [ERROR] Here's an error has been introduced.
f12ef84 [UPDATE] New words.
3f1a4b3 [UPDATE] Now say hello!
3df8afb [UPDATE] Assign the function to variable.
867b7da [NEW] hello.php.
krisanalfatimur@supernova ~/Temp/test (git)-[master] %
krisanalfatimur@supernova ~/Temp/test (git)-[master] % php hello.php
PHP Parse error:  syntax error, unexpected 'broken' (T_STRING) in /Users/krisanalfatimur/Temp/test/hello.php on line 8

Parse error: syntax error, unexpected 'broken' (T_STRING) in /Users/krisanalfatimur/Temp/test/hello.php on line 8

255 krisanalfatimur@supernova ~/Temp/test (git)-[master] % git log --oneline                                                                                                      :(
c470042 [ADD] New method to determine the number of cigarrete.
6ab57ea [ERROR] Here's an error has been introduced.
f12ef84 [UPDATE] New words.
3f1a4b3 [UPDATE] Now say hello!
3df8afb [UPDATE] Assign the function to variable.
867b7da [NEW] hello.php.
krisanalfatimur@supernova ~/Temp/test (git)-[master] % git bisect start
krisanalfatimur@supernova ~/Temp/test (git)-[master|bisect] % git bisect bad c470042
krisanalfatimur@supernova ~/Temp/test (git)-[master|bisect] % git bisect good 867b7da
Bisecting: 2 revisions left to test after this (roughly 1 step)
[3f1a4b33e397928596c71db7eceef4250e925ab3] [UPDATE] Now say hello!
krisanalfatimur@supernova ~/Temp/test (git)-[3f1a4b3...|bisect] % php hello.php
Hello, Alfa!
Hello, Putra!
Hello, Farid!
Hello, Wahyu!
krisanalfatimur@supernova ~/Temp/test (git)-[3f1a4b3...|bisect] % git bisect good
Bisecting: 0 revisions left to test after this (roughly 1 step)
[6ab57ea4e9478070e51b6816730bbdfeddaa204e] [ERROR] Here's an error has been introduced.
krisanalfatimur@supernova ~/Temp/test (git)-[6ab57ea...|bisect] % php hello.php
PHP Parse error:  syntax error, unexpected 'broken' (T_STRING) in /Users/krisanalfatimur/Temp/test/hello.php on line 8

Parse error: syntax error, unexpected 'broken' (T_STRING) in /Users/krisanalfatimur/Temp/test/hello.php on line 8

<?php
255 krisanalfatimur@supernova ~/Temp/test (git)-[6ab57ea...|bisect] % git bisect bad                                                                                              :(
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[f12ef84a85c37728ad5025ea4db5c11f7087e4bb] [UPDATE] New words.
krisanalfatimur@supernova ~/Temp/test (git)-[f12ef84...|bisect] % php hello.php
Alfa holds 1 cigarrete(s).
Putra holds 2 cigarrete(s).
Farid holds 3 cigarrete(s).
Wahyu holds 4 cigarrete(s).
krisanalfatimur@supernova ~/Temp/test (git)-[f12ef84...|bisect] % git bisect good
6ab57ea4e9478070e51b6816730bbdfeddaa204e is the first bad commit
commit 6ab57ea4e9478070e51b6816730bbdfeddaa204e
Author: Krisan Alfa Timur <krisan47@gmail.com>
Date:   Thu Dec 18 17:58:14 2014 +0700

    [ERROR] Here's an error has been introduced.

:100644 100644 bdd1426b22740439b70142e8cc62482771b74a8f 4b0dbc94627d77d8d9fb3a7570be9d8bec0105a1 M	hello.php
krisanalfatimur@supernova ~/Temp/test (git)-[f12ef84...|bisect] % git bisect reset
Previous HEAD position was f12ef84... [UPDATE] New words.
Switched to branch 'master'
krisanalfatimur@supernova ~/Temp/test (git)-[master] % git show 6ab57ea4e9478070e51b6816730bbdfeddaa204e
commit 6ab57ea4e9478070e51b6816730bbdfeddaa204e
Author: Krisan Alfa Timur <krisan47@gmail.com>
Date:   Thu Dec 18 17:58:14 2014 +0700

    [ERROR] Here's an error has been introduced.

diff --git a/hello.php b/hello.php
index bdd1426..4b0dbc9 100644
--- a/hello.php
+++ b/hello.php
@@ -4,6 +4,9 @@ $names = ['Alfa', 'Putra', 'Farid', 'Wahyu'];

 function theFunction($name, $index) {
     $number = $index+1;
+
+    some broken string here LOL
+
     echo("$name holds $number cigarrete(s).\r\n");
 };

krisanalfatimur@supernova ~/Temp/test (git)-[master] % git checkout -b fix_for_bug_6ab57ea
Switched to a new branch 'fix_for_bug_6ab57ea'
krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % php hello.php
PHP Parse error:  syntax error, unexpected 'broken' (T_STRING) in /Users/krisanalfatimur/Temp/test/hello.php on line 8

Parse error: syntax error, unexpected 'broken' (T_STRING) in /Users/krisanalfatimur/Temp/test/hello.php on line 8

255 krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % vim hello.php                                                                                             :(
krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % vim hello.php
krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % php hello.php
Alfa holds 1 cigarrete.
Putra holds 2 cigarretes.
Farid holds 3 cigarretes.
Wahyu holds 4 cigarretes.
krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % git diff --cached
krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % git diff --staged
krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % git diff HEAD
diff --git a/hello.php b/hello.php
index 99775b6..ec16089 100644
--- a/hello.php
+++ b/hello.php
@@ -5,7 +5,6 @@ $names = ['Alfa', 'Putra', 'Farid', 'Wahyu'];
 function theFunction($name, $index) {
     $number = $index+1;

-    some broken string here LOL

     $cig = ($number > 1) ? 'cigarretes' : 'cigarrete';

krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % git commit -am "[FIX] Solve bug for revhash: 6ab57ea."
[fix_for_bug_6ab57ea 82201b4] [FIX] Solve bug for revhash: 6ab57ea.
 1 file changed, 1 deletion(-)
krisanalfatimur@supernova ~/Temp/test (git)-[fix_for_bug_6ab57ea] % git checkout master
Switched to branch 'master'
krisanalfatimur@supernova ~/Temp/test (git)-[master] % git merge fix_for_bug_6ab57ea
Updating c470042..82201b4
Fast-forward
 hello.php | 1 -
 1 file changed, 1 deletion(-)
krisanalfatimur@supernova ~/Temp/test (git)-[master] % git status
On branch master
nothing to commit, working directory clean
krisanalfatimur@supernova ~/Temp/test (git)-[master] % git log --oneline
82201b4 [FIX] Solve bug for revhash: 6ab57ea.
c470042 [ADD] New method to determine the number of cigarrete.
6ab57ea [ERROR] Here's an error has been introduced.
f12ef84 [UPDATE] New words.
3f1a4b3 [UPDATE] Now say hello!
3df8afb [UPDATE] Assign the function to variable.
867b7da [NEW] hello.php.
krisanalfatimur@supernova ~/Temp/test (git)-[master] % php hello.php
Alfa holds 1 cigarrete.
Putra holds 2 cigarretes.
Farid holds 3 cigarretes.
Wahyu holds 4 cigarretes.
krisanalfatimur@supernova ~/Temp/test (git)-[master] % cat hello.php
<?php

$names = ['Alfa', 'Putra', 'Farid', 'Wahyu'];

function theFunction($name, $index) {
    $number = $index+1;


    $cig = ($number > 1) ? 'cigarretes' : 'cigarrete';

    echo("$name holds $number $cig.\r\n");
};

array_walk($names, 'theFunction');
krisanalfatimur@supernova ~/Temp/test (git)-[master] %
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment