I give a try, please comment since not totally sure, but I believe it does the job.
The following will work only if the branches still point at the tip of before being merged into master, which is the case if the branches were on the same repo:
o [master]
|
o merged branch "great-feature" into master
|\
| o A [great-feature]
| |
o | B
| |
If it it not the case (for example if you pulled from another repo) you can still recreate them by hand.
First get the branches where your commit are:
$ git branch -a --contains=<sha-of-B>
*master
great-feature
then for each branch get the number of commits that separate their head to the commit: this is the number of lines that output git log for the specified range:
$ git log --pretty=oneline <sha-of-B>..great-feature | wc -l
1
$ git log --pretty=oneline <sha-of-B>..master | wc -l
4
So B is nearest to great-feature, which means it was created in it.
This could be made into a nice script, feel free to add it to the answer (I'm not good at this)