This follows simply from the fact that levi civita connection is defined in such a way that the energy integrals over geodesics be stationary. Hamiltionian vector fields are time flows of sympletic manifolds given by the principle of extreme action. If your action consists only of the hamiltonian in question, extremizing it will give geodesics as integral curves of the hamiltonian vector field.