Proving Diamond-Shurman Exercise 2.4.7. I am reading chapter 2 of A First Course in Modular Forms and doing its exercises, but I get stuck in Exercise 2.4.7:

Suppose that $\Gamma_1$ and $\Gamma_2$ are congruence subgroups of $\mathrm{SL}_2(\mathbb{Z})$ and that $\gamma$ is an element of $\mathrm{GL}_2^+(\mathbb{Q})$ such that $\gamma \Gamma_1 \gamma^{-1} \subset \Gamma_2$. Show that the formula $\Gamma_1 \tau \mapsto \Gamma_2 \gamma(\tau)$ defines a holomorphic map $X(\Gamma_1) \rightarrow X(\Gamma_2)$.

Here $\mathrm{GL}_2^+(\mathbb{Q})$ refers to general linear group of $2$-by-$2$ matrices with rational entries and positive determinants, and $X(\Gamma)$ means the compactified modular curve (adding the cusps) with respect to $\Gamma$.
I've finished proving on non-cusps points, but I can't show the holomorphy on cusps. Using notations from the book, let $s \in \mathbb{Q} \cup \{\infty\}$, then $\gamma(s) \in \mathbb{Q} \cup \{\infty\}$, too. Denote the given map $X(\Gamma_1) \rightarrow X(\Gamma_2)$ as $F$. About $s$ and $\gamma(s)$ we take neighborhoods $U_1$ and $U_2$ in $\mathcal{H}^* (= \mathcal{H} \cup \{\infty\} \cup \mathbb{Q})$. Write $\pi_j: \tau \mapsto \Gamma_j \tau$ for $j = 1, 2$. We may assume that $\pi_1(U_1) \subset F^{-1}(\pi_2(U_2))$. Let $\delta_1$ be the striaghtenint map ($\delta_1 \in \mathrm{SL}_2(\mathbb{Z})$ and $\delta_1(s) = \infty$) and $\rho_1: z \mapsto \exp(2 \pi i \delta_1(\tau)/h_1)$ be the wrapping map, where
\begin{align*}
h_1 = \left| \frac{\mathrm{SL}_2(\mathbb{Z})_s}{\{\pm I\} (\Gamma_1)_s} \right|
\end{align*}
is the width of $s$. Then the local chart centered at $\Gamma_1 s$ is
\begin{align*}
\phi_1: \pi_1(U_1) &\longrightarrow V_1, \quad \phi_1 = \rho_1 \circ \delta_1 \circ \pi_1^{-1} \\
\Gamma_1 \tau &\longmapsto \exp(2 \pi i \delta_1(\tau)/h_1)
\end{align*}
Similarly the local chart of $X(\Gamma_2)$ about $\Gamma_2 \gamma(s)$ is $\phi_2: \pi_2(U_2) \rightarrow V_2$. The map $F$ In terms of local coordinates is
\begin{align*}
\phi_2 \circ F \circ \phi_1^{-1}: V_1 &\longrightarrow V_2 \\
\exp(2 \pi i \delta_1(\tau)/h_1) &\longmapsto \exp(2 \pi i \delta_2 \gamma(\tau)/h_2).
\end{align*}
We know that $\delta_2 \gamma \delta_1^{-1} \in \mathrm{GL}_2^+(\mathbb{Q})$ and fixes $\infty$, so \begin{align*}
\delta_2 \gamma \delta_1^{-1} = 
\begin{bmatrix} x & y \\
 0 & z
\end{bmatrix} \quad \text{ for some } x, y, z \in \mathbb{Q}
\end{align*}
and the expression above can be rewritten as
\begin{align*}
q = \exp(2 \pi i \delta_1(\tau)/h_1) &\longmapsto \exp(2 \pi i \delta_2 \gamma(\tau)/h_2) = \exp(\frac{2 \pi i y}{z h_2}) \cdot q^{(h_1 x)/(z h_2)}.
\end{align*}
How to show that it is holomorphic?
 A: Here’s the short version (that needs some complex analysis): $F$ is continuous and holomorphic at every point but finitely many. In the charts, you can then apply Morera’s theorem to show that it is holomorphic (seen another way, in a chart, singularities given by points of non-holomorphicity are removable since the map is continuous).
Here’s the version where you  work with congruence subgroups: we’ll assume for the sake of simplicity that $-I_2 \in \Gamma_1 \cap \Gamma_2$.
Now, we know that $\delta_1^{-1}\begin{bmatrix}1&h_1 \\0 &1\end{bmatrix}\delta_1 \in \Gamma_1$ and maps $s$ to $s$. Thus $M=\gamma \delta_1^{-1}\begin{bmatrix}1&h_1 \\0 &1\end{bmatrix}\delta_1\gamma^{-1} \in \Gamma_2$, and it maps $\gamma(s)$ to $\gamma(s)$, so that $M’=\delta_2M\delta_2^{-1}=\pm \begin{bmatrix}1&nh_2 \\0&1\end{bmatrix}$.
But let $P=\delta_2\gamma\delta_1^{-1}$: then $M’=P\begin{bmatrix}1 &h_1 \\0&1\end{bmatrix}P^{-1}$ so the trace of $M’$ is $2$ and thus the undetermined sign above is $+$.
It follows (with your notations) that $\begin{bmatrix}x &y+znh_2\\0&z\end{bmatrix}=\begin{bmatrix}x &xh_1+y \\0&z\end{bmatrix}$. So $\frac{xh_1}{zh_2}=n \in \mathbb{Z}$ and the conclusion follows.
