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