If $g_m\geq 0$ then $\int \sum_{m=0}^{\infty} g_m d\mu =\sum_{m=0}^{\infty} \int g_m d\mu$.
I have proved the part that if $\int \sum_{m=0}^{\infty} g_m d\mu$ is finite then the equality holds.
But I could not find a way to prove that--- if $\int \sum_{m=0}^{\infty} g_m d\mu$ is infinite but none of $\int g_m d\mu$ are infinite, then also the equality holds.
Suppose that $A=\sum_{m=0}^\infty\int g_m$ is finite. Then $\int h_M\le A$ where $h_M=\sum_{m=0}^M g_m$. The sequence $(h_M)$ is pointwise increasing. By the Monotone Convergence Theorem, $H=\lim_{M\to\infty} $ is integrable and $\int H=\lim_{n\to\infty}\int h_M$. This is the equality you seek.
In all other cases both sides are $\infty$.