0 votes
1 view
in DevOps and Agile by (20k points)

Is there any way to find out what branch a commit comes from given its sha1?

Bonus points if you can tell me how to accomplish this using Ruby Grit.

1 Answer

0 votes
by (28.4k points)

This command should do the magic:

$ git name-rev <SHA>

For example: 

Branch name: new-branch

$ git name-rev 651ad3a251ad3a remotes/origin/new-branch

Even this is working for complex scenarios like:

origin/branchA/

              /branchB

                      /commit<SHA1>

                                   /commit<SHA2>

Here, git name-rev commit<SHA2> returns branchB

Welcome to Intellipaat Community. Get your technical queries answered by top developers !

Categories

...