I'm trying to show the above as simply as possible; I suspect that the method I have is somewhat overcomplicated. From looking at the Cayley diagrams of the groups, it is clear that $\varphi: G_2 \to G_1$ given by $a \mapsto x^2, b \mapsto y^2$ is such a homomorphism.
It is easy to check that this map does actually satisfy the defining relation of $G_2$, and hence induces a well-defined homomorphism.
As for injectivity, suppose that $g \in G_2$ has $\varphi(g) = e$. Since the generators $a, b$ of $G_2$ commute, we may assume without loss of generality that $g = a^mb^n$ for some $m, n \in \mathbb{Z}$, so that $x^{2m}y^{2n} = e$.
Now, we may define $f:G_1 \to \mathbb{Z}$ to be the homomorphism with $x \mapsto 1, y \mapsto 0$ (which may easily be seen to satisfy the defining relation of $G_1$). Then we have that $0 = f(e) = f(x^{2m}y^{2n}) = 2m$, so $m = 0$, and hence $y^{2n}=e$.
It remains to show that $y$ has infinite order in $G_1$, and this is where I get a bit stuck. I can see two ways to complete the proof, but both are quite cumbersome and I feel like there should be an easier way.
The first approach I can see is to define an explicit binary operation on $\mathbb{Z} \times \mathbb{Z}$ by $(p,q) * (m,n) = (m + (-1)^{n}p, n + q)$ and define a homomorphism from $G_1$ to this group by mapping $x, y$ to its generators in the appropriate way. This is quite confusing, and verifying that the defining relation is satisfied takes a relatively long time.
Alternatively, we could observe that the dihedral group $D_{2n}$ with $2n$ elements has presentation $\langle \sigma, \tau \mid \tau\sigma\tau^{-1}\sigma, \sigma^n, \tau^2\rangle$, which means that we can define a homomorphism from $G_1$ to $D_{2n}$ sending $y$ to $\sigma$, which implies that $y$ has order at least $n$. Thus, fro, since $n$ is arbitrary, we see that indeed $y$ has infinite order.
All this is quite convoluted. Can anybody see a simpler justification? Thank you!
It is enough to construct a subgroup in $G_1$ that has the same presentation of $G_2$.
It is easy to see that if $xyx^{-1}y=e$ then $xy=y^{-1}x$. Taking inverse both sides one gets $y^{-1}x^{-1}=x^{-1}y$, so
$$xy^{-1}=yx.$$
Let's take $\langle x^2,y\rangle$ on $G_1$. We can see \begin{eqnarray*} x^2y&=&xxy\\ &=&xy^{-1}x\\ &=&yx^2. \end{eqnarray*} With this we had shown that the subgroup complies $\langle x^2,y\ |\ x^2y=yx^2\rangle$ and it has the same presentation $\langle a,b\ |\ ab=ba\rangle$ of $G_2$, hence via the extension of the assigment given by $$a\mapsto x^2,$$ $$b\mapsto y,$$ to a homomorphism, this would be an isomorphism.