As a complement to YCor's elegant answer, I would like to present **three additional ways** to prove

>> **YCor's Statement 1.** The groups $G_m$ and $G_n$ are isomorphic if and only if $m = n$.

The first method mimics YCor's, but we will use the theory of [right-angled Artin groups][4] (aka partially commutative groups, or graph groups) instead of Bass-Serre theory. The second is prompted by YCor's proof and relies on the cohomological dimension of $G_n$: we will show that $\text{cd}(G_n) = n + 1$. These two methods enable us to retrieve YCor's stronger statement

>> **YCor's Statement 2.** The maximal rank $a(G_n)$ of a free Abelian subgroup of $G_n$ is $n + 1$. 

The last method relies on the computation of the second homology group (also called [Schur multiplier][5]) of $G_n$. We will establish $\text{H}_2(G_n, \mathbb{Z}) \simeq \mathbb{Z}^n$, which yields, as we will see, some other benefit.


>> **Claim 1.** Let $\Gamma_n$ be the simplicial graph with vertex group $\mathbb{Z}$ and where an edge binds $i$ to $j$ if and only if $\vert i - j \vert \le n$. Then $G_n \simeq S(\Gamma_n) \rtimes \mathbb{Z}$ where 
$$S(\Gamma_n) \Doteq \langle s_i, \, i \in \mathbb{Z} \,\vert\, [s_i, s_j] = 1 \text{ for every } i, j \in \mathbb{Z} \text{ such that } \vert i - j \vert \le n \rangle$$ is the right-angled Artin group associated to $\Gamma_n$ and the canonical generator $a$ of $\mathbb{Z}$ acts on $S(\Gamma_n)$ as the right shift operator, i.e., $a^{-1}s_ia = s_{i + 1}$. In addition, any Abelian free subgroup of rank $ > 1$ of $G_n$ is a subgroup of $S(\Gamma_n)$. In particular, $$a(G_n) = a(S(\Gamma_n)) = n + 1.$$

>> *Proof.* Setting as YCor, $s_k \Doteq a^{-k}ba^{k}$ for all $k \in \mathbb{Z}$, we obtain in a similar way $$G_n = \langle a, s_i, \, i \in \mathbb{Z} \,\vert\, a^{-1}s_ka = s_{k + 1},\,[s_i, s_j] = 1 \text{ for all } k, i, j \in \mathbb{Z} \text{ with } \vert i - j \vert \le n \rangle.$$
Hence $G_n \simeq S(\Gamma_n) \rtimes \mathbb{Z}$.
 To prove the second part of the claim, we consider the basis $t_1 = \sigma_1a^{i_1}, \dots, t_k = \sigma_k a^{i_k}$, with $\sigma_i \in S(\Gamma_n) $, of a free Abelian subgroup of $G_n$ of rank $k > 1$. Replacing, if needed, $(t_1, \dots, t_k)$ by a Nielsen-equivalent $k$-tuple, we can assume that $i_j = 0$ for every $j > 1$ (use the projection $G_n \twoheadrightarrow \mathbb{Z}$ and the Euclidean algorithm in $\mathbb{Z}$). It follows from the Normal Form Theorem of right-angled Artin group [2] that $t_1$ commutes with $t_2$ only if $i_1 = 0$. Thus $\langle t_1, \dots, t_k \rangle \subset S(\Gamma_n)$. It is well-known that for $S(\Gamma)$, the right-angled Artin group associated to a graph $\Gamma$, the number $a(S(\Gamma))$ is the clique number of $\Gamma$, that is the number of vertices in a maximal complete subgraph of $\Gamma$. Obviously, this number is $n + 1$ for $\Gamma_n$.

The cohomological dimension of a group $G$ is 
$\text{cd}(G) = \sup \left\{ q \, \vert \, \text{H}^q(G, \mathbb{Z}) \neq 0 \right\}$ [Section VIII.2, 3]
Here is our second proof of YCor's statements.

>> **Claim 2.** $\text{cd}(G_n) = n + 1$.

>> *Proof*. Given a group $G$, a subgroup $S \subset G$ and an injective homomorphism $\tau: S \rightarrow G$, let $T = \tau(S)$ and let $\tilde{G}$ denote the corresponding $HNN$ extension, i.e., $\tilde{G} = \langle G, a \, \vert \, a^{-1}sa = \tau(s), \text{ for all } s \in S \rangle$. By [Theorem 2.12, 1], there is a Mayer-Vietoris sequence
$$
\cdots 
\rightarrow 
\text{H}^{q - 1}(S, \mathbb{Z}) 
\mathop{\rightarrow}^{\delta} 
\text{H}^q(\tilde{G}, \mathbb{Z}) 
\mathop{\rightarrow}^{\text{res}} 
\text{H}^q(G,\mathbb{Z}) 
\mathop{\rightarrow}^{\text{res}_S - \tau^{\ast} \circ \text{res}_T} \text{H}^q(S, \mathbb{Z}) 
\rightarrow 
\cdots
$$
Set $G = \langle s_0, \dots, s_n \rangle$, the free Abelian group generated by the $s_i$ for $0 \le i \le n$, and $S = \langle s_1, \dots, s_n \rangle$, $\tau: S \rightarrow G$ is the homomorphism induced by the right shift of indices. As shown by YCor, we have then $\tilde{G} = G_n$.
Since $\text{cd}(\mathbb{Z}^q) = q$ for $q = n, n + 1$, the above exact sequence yields the result.

Since $\text{cd}(H) \le \text{cd}(G)$ whenever $H$ is a subgroup of $G$ [Proposition VIII.2.4, 3], it follows from **Claim 2** that $a(G_n) = n + 1$.

Let $F(a, b)$ the free group over the alphabet $\{a,b\}$ and let $r_i = [b, a^{-i}ba^i] \in F(a,b)$. We denote by $R_n$ the normal subgroup of $F(a, b)$ generated by $r_1, \dots, r_n$. By Hopf's theorem [Theorem II.5.3, 3], we have
$$\text{H}_2(G_n, \mathbb{Z}) \simeq \frac{ R_n}{[F(a,b), R_n]}$$

>> **Claim 3.** The Abelian group $\text{H}_2(G_n, \mathbb{Z})$ is freely generated by the images of $r_1, \dots, r_n$. In particular, $\text{H}_2(G_n, \mathbb{Z})  \simeq \mathbb{Z}^n$.

>> *Proof.* We reuse the notation of the proof of Claim 2, in particular $\tilde{G} = G_n$. 
By [Theorem 2.12, 1], there is a Mayer-Vietoris sequence
$$
\cdots 
\rightarrow 
\text{H}_{q}(S, \mathbb{Z}) 
\mathop{\rightarrow}^{\text{cores}_S - \text{cores}_T \circ \tau_{\ast}} 
\text{H}_q(G, \mathbb{Z}) 
\mathop{\rightarrow}^{\text{cores}} 
\text{H}_q(\tilde{G},\mathbb{Z}) 
\mathop{\rightarrow}^{\partial} \text{H}_{q - 1}(S, \mathbb{Z}) 
\rightarrow 
\cdots
$$
Since $$S \simeq \text{H}_{1}(S, \mathbb{Z}) 
\mathop{\rightarrow}^{\text{cores}_S - \text{cores}_T \circ \tau_{\ast}} 
\text{H}_1(G, \mathbb{Z}) \simeq G$$ is given by $s_i \mapsto s_i - s_{i + 1}$ for $0 \le i \le n - 1$, this homomorphism is injective.  Therefore $\text{H}_2(\tilde{G}, \mathbb{Z})$ is isomorphic to the quotient of $\text{H}_2(G, \mathbb{Z})$ by the image of $\text{H}_2(S, \mathbb{Z})$ via $\text{cores}_S - \text{cores}_T \circ \tau_{\ast}$. 
By [Theorem V.6.4, 3], the homomorphism 
$$\Lambda^2(S, \mathbb{Z}) \simeq \text{H}_{2}(S, \mathbb{Z}) 
\mathop{\rightarrow}^{\text{cores}_S - \text{cores}_T \circ \tau_{\ast}} 
\text{H}_2(G, \mathbb{Z}) \simeq \Lambda^2(G, \mathbb{Z})$$ is given by $s_i \wedge s_j \mapsto s_i \wedge s_j - s_{i + 1} \wedge s_{j + 1}$ for $0 \le i, j \le n - 1$. Thus $\text{H}_2(\tilde{G}, \mathbb{Z}) \simeq \mathbb{Z}^n$. As the images of $r_1, \dots, r_n$ generates $\text{H}_2(\tilde{G}, \mathbb{Z})$ by Hopf's formula, these elements are necessarily independent over $\mathbb{Z}$.

It follows from **Claim 3** that the presentation $\langle a,b \, \vert r_i = 1,\, i = 1,\dots, n \rangle$ is minimal in the sense that removing any defining relations yields a non-isomorphic extension. Moreover, any presentation of $G_n$ must involve at least $n$ relators.

>> **Claim 4.** The cohomological dimension of 
$\mathbb{Z} \wr \mathbb{Z} = \langle a,b \, \vert r_i = 1,\, i \ge 1 \rangle$ is infinite and 
$\text{H}_2(\mathbb{Z} \wr \mathbb{Z}, \mathbb{Z})$ is a free Abelian group of infinite countable rank.

>>*Proof.* The subgroup $S$ of $\mathbb{Z} \wr \mathbb{Z}$ generated by $s_0, s_1, \dots$ is a free Abelian group of infinite countable rank, therefore $\text{cd}(\mathbb{Z} \wr \mathbb{Z}) = \infty$. The last part of the claim is obtained as in the proof of Claim 3, observing that $\mathbb{Z} \wr \mathbb{Z} \simeq S \rtimes \mathbb{Z}$ where the canonical generator of $\mathbb{Z}$ acts on $S$ by shifting indices on the right.

---

[1] R. Bieri. "Homological dimension of discrete groups", 1981.  
[2] A. Baudisch. "Subgroups of semifree groups", 1981.  
[3] K. Brown. "Cohomology of groups", 1982.  

[4]: https://en.wikipedia.org/wiki/Artin_group#Right-angled_Artin_groups
[5]: https://en.wikipedia.org/wiki/Schur_multiplier