Is there a way to find out what branch a commit comes from given its SHA-1 hash value?
Bonus points if you can tell me how to accomplish this using Ruby Grit.
khichar.anil covered most of this in his answer.
I am just adding the flag that will remove the tags from the revision names list. This gives us:
git name-rev --name-only --exclude=tags/* $SHA