This follows simply from the fact that levi civita connection is defined in such a way that the energy integrals over geodesics be stationary.