Tuesday, December 2, 2014

Finding a specific commit in GIT

An issue that I came across recently is, checking if a certain commit is present in a branch or tag.

This could be usefull if you want to know if a certain bugfix has been deployed to a certain branch/tag.

Doing this is quite easy, say we want to find a commit containing 'puppies':
git log --all --grep='puppies'
This will return you the commits containing puppies. ( eg. edd12e3d44364957832a0a74169469a1 )

To find all branches, use:
git branch --contains edd12e3d44364957832a0a74169469a1
To find all tags, use:
git tag --contains edd12e3d44364957832a0a74169469a1