I dont understand the following detail
$$ \frac{1}{2} \int_a^b \frac{d}{dt}(g(X,X)ds = \int_a^bg(\nabla_YX, X)$$
Here $X = d\phi (\partial/\partial s)$ and $Y =d\phi (\partial/\partial t)$. Where $\phi:(-\epsilon, \epsilon)\times I \rightarrow M : \phi: (t,s) \rightarrow \phi(t,s)$.
In our course we define $\textbf{metric}$ as a connection $\nabla$ such that $$X(g(Y,Z) = g(\nabla_XY,Z) + g(\nabla_XZ,Y),$$ where $X,Y,Z$ is vector fields.
I fail to see why this is true. Can someone please explain.
Of course, metric is not a connection. However, for a Riemannian metric $g$ one defines (and uses!) $g$-compatible connections $\nabla$ such that the parallel transport via $\nabla$ preserves the metric $g$. Equivalently, for all smooth vector fields $X, Y, Z$: $$ X(g(Y,Z))= g(\nabla_X Y, Z) + g(Y, \nabla_X Z). $$ This will be explained in pretty much any Riemannian Geometry textbook (my personal favorite is do Carmo's "Riemannian Geometry"). You can think of this formula as the "product rule" for the differentiation via the vector field $X$.
Edit. Here are some details ("low brow", avoiding discussion of pull-back of bundles and connections), mostly following do Carmo's book "Riemannian Geometry":
Definition. An affine connection $\nabla$ on a manifold $M$ is said to be compatible with a Riemannian metric $g$ if parallel transport along curves defined by $\nabla$ preserves the metric $g$.
Step 1. (Proposition 3.2 in do Carmo's book) A connection $\nabla$ is compatible with $g$ if and only if for every curve $c: I\to M$ and a pair of vector field $V, W$ along $c$, we have the "Riemannian Product Rule" $$ (1)~~~~~~~~~~~~~~~~~~ \frac{d}{dt} g(V,W)= g(\frac{DV}{dt}, W) + g(V, \frac{DW}{dt}). $$ The proof (in do Carmo) of the non-obvious implication (from compatibility to the product rule) is rather straightforward, by writing $V, W$ in terms of orthonormal parallel bases of vector fields along $c$ and then applying the Product Rule from Calculus.
Step 2. (Corollary 3.3 in do Carmo's book): A connection $\nabla$ is compatible with $g$ if and only if $$ (2)~~~~~~~~~~~~~~~~~~ X(g(Y,Z))= g(\nabla_X Y, Z) + g(Y, \nabla_X Z) $$ for all vector fields $X, Y, Z$ on $M$.
Proof. Suppose that $\nabla$ is compatible with $g$. Take $p\in M$ and let $c: I\to M$ be a curve with $c(t_0)=p, c'(t_0)=X(p)$. Then (by Step 1) $$ X(p) g(Y,Z)= \frac{d}{dt} g(Y,Z)|_{t_0}= g_p(\nabla_{X(p)} Y, Z) + g_p(Y, \nabla_{X(p)} Z), $$ hence, implying the equation (2). For the opposite implication do Carmo goofed (one of the few places in the book where he did) and said that it is obvious (it is not). Here is the proof.
Define the closed subset $J\subset I$ to be the critical set of $c$, i.e. $J$ consists of points $t$ such that $c'(t)=0$.
Case a. Suppose that $t_0\notin J$. Then there is an open interval $I_0\subset I$ containing $t_0$ such that $c|_{I_0}$ is an embedding. Hence, the vector fields $V, W$ along $c$, restricted to $I_0$ extend to smooth vector fields $Y, Z$ on $M$, while the tangent field $c'|_{I_0}$ extends to a vector field $X$ on $M$. Now, the equation (1) at $t_0$ indeed immediately follows from the equation (2).
Case b. Suppose that $t_0$ belongs to the interior of $J$. Then there is an open interval $I_0\subset I$ containing $t_0$ such that $c$ is constant on $I_0$, $c(t)=p, t\in I_0$. Then we do not even need the metric compatibility condition and the proof is a Calculus argument. The vector fields $V, W$ along $c$, restricted to $I_0$ become smooth maps $I_0\to T_pM$. Then, writing $\frac{D}{dt}$ in local coordinates at $p$ (where $g_p=\delta_{ij}$) we obtain: $$ \frac{DV}{dt}= \frac{dV}{dt}, \frac{DW}{dt}= \frac{dW}{dt} $$ (the "calculus derivative" for maps $V, W: I_0\to T_pM$). Indeed, writing $V=\sum_i v^i e_i$, where $\{e_1,...,e_n\}$ is an orthonormal basis in $T_pM$, we have $$ \frac{DV}{dt}= \sum_k \left( \frac{dv^k}{dt} + \sum_{i,j} v^j c'_i(t_0) \Gamma^k_{ij}\right)e_k= \sum_k \frac{dv^k}{dt}e_k =\frac{dV}{dt}, $$ since $c'(t_0)=0$.
Thus, on the interval $I_0$, we have $$ g_p(V,W)= V\cdot W $$ and the equation $$ \frac{d}{dt} V\cdot W= \frac{dV}{dt} \cdot W + V\cdot \frac{dW}{dt} $$ is just the Product Rule from Calculus.
Case c. Suppose that $t_0\in I$ lies on the boundary of $J$. Then the equality (1) follows from Case (a) by continuity.
When I teach RG (I use do Carmo's book), I usually give this proof and later on discuss connections on general vector bundles and explain that vector fields along curves/surfaces are sections of pull-back bundles and that $\frac{D}{dt}$ is the pull-back connection and then give a "high-brow" proof of the fact that pull-back of a parallel covariant tensor is again parallel.