Git: Prefer first match on Push to Gerrit with detached head

Following matches are likely to be merges, and not the branch that the
first commit originated from.

Change-Id: I80a442bf9f7bc7f5859a1f4c3d3e167d55b28241
Reviewed-by: Petar Perisin <petar.perisin@gmail.com>