Git Bisect to the Rescue

Git bisect is awesome! Awesome.

Most of you probably know it, but for anyone who doesn’t. this is a good tutorial.

A huge unwanted margin had appeared to the right of my container on mobile and tablet sizes.

Poked around in firebug for a bit unsuccessfully.

SO…

$ gitk

Find an old commit

$ git checkout [old_commit_hash]
$ gulp

Reload browser. The margin’s gone! Make not of the [old_commit_hash].

$ git checkout master

This step is important, 'cause at the end of bisect reset takes you back to last checkout out commit.

$ git bisect start
$ git bisect bad
$ git bisect good [old_commit_hash]

Then git checks out a commit half way in between.

$ gulp

Reload browser. And either $ git bisect good or $ git bisect bad.

Git keeps going half way until there are no bisections left. Then use gitk to look through the code changes introduced in that commit and find the error of your ignorant ways. Fix it. $ gulp. Reload. Good!

$ git commit -am "fixed that pesky bla bla bla."
$ git bisect reset

Now you are back on master with your updated code change. Awesome.

1 Like