The first exercise in Serre’s book *[Trees](https://doi.org/10.1007/978-3-642-61856-7)* spells this out (I’ve corrected a missing “normal”):

Let $f_1\colon A \to G_1$ and $f_2\colon A \to G_2$ be two homomorphisms and let $G$ be their pushout. We define subgroups $A^n$, $G^n_1$ and $G^n_2$ of $A$, $G_1$ and $G_2$ recursively by the following conditions:

- $A^1 = \{1\}, \qquad G^1_1=\{1\}, \qquad G^1_2 = \{1\}$

- $A^n = $ normal subgroup of $A$ generated by $f^{-1}_1(G^{n-1}_1)$ and $f^{-1}_2(G^{n-1}_2)$

- $G^n_i = $ normal subgroup of $G_i$ generated by $f_i(A^n)$.

Let $A^\infty$, $G^\infty_i$ be the unions of the $A^n$, $G^n_i$, respectively. Show that $f_i$ defines an *injection* $A/A^\infty \to G_i/G^\infty_i$ and that $G$ may be identified with the amalgam of $G_1/G^\infty_1$ and $G_2/G^\infty_2$ along $A/A^\infty$.

It follows (using the results of no. 1.2 in *Trees*) that the kernel of $A\to G$ is $A^\infty$ and that the kernel of $G_i \to G$ is $G_i^\infty$.