More productive Git

These tips and techniques by James Turnbull will help you to avoid potential source control pitfalls and make your development workflow bit smoother.

Tip # 6: I am bisect and so can you

git bisect is one of the most powerful, seemingly magical, code-based debugging tools available to you. It can be used when you discover a bug you can’t trace to a specific piece of code. A git bisect runs a binary search between two commits: a good commit where the bug wasn’t present and a bad commit where the bug appears.

$ git bisect start
$ git bisect bad                 # Current version is bad
$ git bisect good v2.6.13-rc2    # v2.6.13-rc2 is known to be good

First Aid Git

A searchable collection of the most frequently asked Git questions. Following are a couple of my most favorite commands from the list:

-- Commit changes to a new branch
git checkout -b my-new-branch-name

-- Move stashed changes to current branch
git stash apply

Another handy Git command I surely want to see in this list is git commit --amend which allows adding changes to your last commit.

-- Add changes to last commit
git commit --amend -m "updated commit message"

--amend flag will tackle situation like:

701c70f Fix issue with api_handler
2e7be87 Update fix to api_handler
7e9f104 Some more fixes to api_handler
16e9747 Last changes to api_handler
3d1e7db This is last change to api_handler
e58043e :(