+1  A: 

How about: git fetch && git branch -r --contains <commit-id>

Brian Phillips
hmmm... I had overlooked the -r option. This would work, but I still think there has to be some plumbing command that I'm missing. And really, I don't care whether or not the current branch's tracking branch contains the commit. I just care that the commit exists in origin, without regard to what branch it's accessible from.
Josh
@Josh: Surely if this is a public release, you do care what branch it's on - it should be on the branch for that specific release.
Jefromi
A: 

I may have overlooked some plumbing too, but as far as I can tell, the most direct way to test if commitA is an ancestor of commitB is to check if git merge-base commitA commitB is commitA. Fetch first, and then since they may be branches, use rev-parse to get an SHA1 for commitA:

if [ "$(git rev-parse $commitA)" == "$(git merge-base $commitA $commitB)" ]; then ...; else ...; fi

Wrap that up in an alias and you should be set.

As for during push and fetch (pull), those are implemented in C, so they're not directly calling any exposed plumbing commands.

Jefromi
A: 

git fetch + git branch -r is the best you could get.

You can hack the git protocol to give this result, but there are no plumbing you can use afaik. See section 5 for details. Just hack the "have" command and check if the server NAK.

A even easier hack is just try to push that commit, see if the server want it.

J-16 SDiZ