Solution (source code)

= Solution

First verify the <difference of affine connections is a tensor>. Linearity over <smooth functions> in $X$ follows from the <affine connection> axioms. In $Y$, the two derivative terms cancel:
$$
A(X,fY)=\nabla_X(fY)-\nabla'_X(fY)=fA(X,Y).
$$
Thus $A$ is a smooth $(1,2)$-<tensor field>, and $A_p(u,v)$ depends only on the tangent vectors $u,v$ at $p$. For any <smooth curve>, its two covariant accelerations satisfy
$$
D_t\dot\gamma-D'_t\dot\gamma=A(\dot\gamma,\dot\gamma).
$$
If $A(X,Y)=-A(Y,X)$, its diagonal values vanish. The two <geodesic equations> are therefore identical, and the connections have the same parametrized <geodesics>.

For necessity, the required local <geodesic> existence theorem is this: for every smooth <affine connection>, $p\in M$ and $v\in T_pM$, a unique <geodesic> exists on some interval about zero with $\gamma(0)=p$ and $\dot\gamma(0)=v$. Indeed the <geodesic equation> is the smooth first-order <ordinary differential equation> on position and velocity
$$
\dot x^k=v^k,\qquad \dot v^k=-\Gamma^k{}_{ij}(x)v^iv^j,
$$
so local existence and uniqueness apply. If the two connections have the same parametrized <geodesics>, apply the acceleration identity to this <geodesic> at zero to obtain $A_p(v,v)=0$ for every $p,v$. Expanding $A_p(u+v,u+v)=0$ gives $A_p(u,v)+A_p(v,u)=0$. Therefore
$$
\boxed{\text{same parametrized geodesics}\quad\Longleftrightarrow\quad
A(X,Y)=-A(Y,X).}
$$
This is the criterion that <parametrized geodesics determine the symmetric part of an affine connection>. It concerns equality with the same affine parameters. Agreement merely of unparametrized images is weaker: adding $\alpha(X)Y+\alpha(Y)X$ to a connection, for a smooth one-form $\alpha$, changes acceleration by a multiple of the velocity, which can be absorbed by reparametrization. Such a difference need not be antisymmetric.

Finally, since $\nabla'_XY=\nabla_XY-A(X,Y)$, expand the derivative of the <metric tensor>:
$$
(\nabla'_Xg)(Y,Z)
=X(g(Y,Z))-g(\nabla'_XY,Z)-g(Y,\nabla'_XZ)
=(\nabla_Xg)(Y,Z)+g(A(X,Y),Z)+g(Y,A(X,Z)).
$$
Under the assumed <metric compatibility> of $\nabla$, the first term is zero. Consequently
$$
\boxed{\nabla' g=0\quad\Longleftrightarrow\quad
g(A(X,Y),Z)=-g(Y,A(X,Z))\quad\text{for all }X,Y,Z.}
$$
Equivalently, for each fixed $X$, the endomorphism $A(X,\cdot)$ is skew-adjoint for the <Riemannian metric>. This metric criterion does not require the two connections to have the same <geodesics>.