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.
This simple command works like a charm:
git name-rev
For example (where test-branch is the branch name):
git name-rev 651ad3a 251ad3a remotes/origin/test-branch
Even this is working for complex scenarios, like:
origin/branchA/ /branchB /commit /commit
Here git name-rev commit returns branchB.
git name-rev commit