TITLE: Help me understand boundary terms in actions over nontrivial manifolds
QUESTION [5 upvotes]: So I have this manifold $M$, along with a metric $g_{\mu\nu}(x)$ and metric-compatible covariant derivative $\nabla_\mu$ (which is not necessarily the one corresponding to the Levi--Civita connection).
When dealing with the action principle, we can ignore boundary terms. My question is, which of the following is a boundary term? Let $g(x) = \mathrm{det}(g_{\mu\nu}(x))$.
$$\int_M \partial_\mu A^\mu \sqrt{|g(x)|} \, \mathrm{d} x$$
or
$$\int_M \nabla_\mu A^\mu \sqrt{|g(x)|} \, \mathrm{d} x \ ?$$
(Or both, or neither? Maybe the latter, but only when $\nabla$ is Levi--Civita?)
I guess my question reduces to, how does Stokes's theorem work for general covariant derivatives, and with the natural volume element $\sqrt{|g(x)|} \, \mathrm{d} x$?

REPLY [3 votes]: It is worth reiterating that there is only one Stokes theorem, so an integral is a "boundary term" if and only if it can be written in local co-ordinates as $\int \partial_\mu(B^\mu)\,dx$. If there is any factor outside the partial derivative, then the Stokes theorem cannot be applied.
So the determinant of the metric must be inside the partial derivative. When you expand out the derivative, Christoffel symbols appear, allowing the integrand to be written in terms of the connection instead.