Sunday, February 10, 2013

What commit/branch contains the change?

Ever have someone show you something in a repository and you can't remember what branch had the change they had shown you? Every forget which branch has a particular commit you made at some point? 

This happens to me more often than I think I would like to admit. With the following two git tricks, you can always figure out exactly where the change is your are looking for.

The first command does two things.
  • expands a listing of all the commits using `git rev-list --all`
  • greps across those commits for the pattern.
The second command identifies which branch(es) the commit resides in.

It's these simple things that make me really love git.