Variation of the kinetic quark term of the QCD Lagrangian under gauge transformation A simple kinetic quark term would look like
$$\bar{\psi}(\gamma^{\mu}\partial_{\mu} - m){\psi}.$$
Imposing SU(3) symmetry the Dirac spinor transforms like
$$\psi(x) \rightarrow \psi'(x) = e^{ig_s \alpha(x)^aT^a}\psi(x),$$
where $T^a$ are the generators of SU(3).
Looking at the infinitesimal transformations of the kinetic term due to this transformation gives:
$$\bar{\psi}(\mathbb{1} - ig_s \alpha^aT^a)(i\gamma^{\mu}\partial_{\mu} - m)(\mathbb{1} + ig_s\alpha^aT^a)\psi =\\
 \bar{\psi}(i\gamma^{\mu}\partial_{\mu} - m)\psi + \bar{\psi}(i\gamma^{\mu}\partial_{\mu} - m)ig_s \alpha^a T^a \psi + \bar{\psi}(-ig_s \alpha^a T^a)(i\gamma^{\mu}\partial_{\mu} - m)\psi + \bar{\psi}(-ig_s\alpha^aT^a)(i\gamma^{\mu}\partial_{\mu} - m)(ig_s \alpha^a T^a)\psi.$$
In the texbtook I'm trying to follow they then skip the calculations and arrive at:
$$ \bar{\psi}(\gamma^{\mu}\partial_{\mu} - m)\psi=\bar{\psi}(i\gamma^{\mu}\partial_{\mu} - m)\psi - \bar{\psi}(g_s i \gamma^{\mu} \partial_{\mu} 
\alpha^a T^a)\psi.$$
I can't seem to reproduce this result. Why do the two terms linear in $g_s$ cancel each other? To do that we would have to know that $T$ and $\gamma$ commute with each other which isn't obvious to me.
And where does the mass term of the term quadratic in $g_s$ vanish to?
 A: The term quadratic in $g_s$ vanished because we are considering transformations infinitesimal in $\alpha$ here, and only linear terms are considered.
To see that $T^a$ and $\gamma^\mu$ commute with each other we can write the kinetic terms expliciting the indices:
$$ \tag{1} \bar \psi (i \gamma^\mu \partial_\mu - m ) \psi
\equiv \bar \psi_{\alpha,i} (i \gamma^\mu_{\alpha\beta} \delta_{ij} \partial_\mu - m \delta_{\alpha \beta} \delta_{ij}) \psi_{\beta,j},$$
where the $i,j$ indices are flavour indices, and come from the fact the spinor fields $\psi$ transform under some representation (in this case the fundamental) of the gauge group (in this case $SU(3)$).
The $\delta_{ij}$ and $\delta_{\alpha \beta}$ terms are there as the components of the identity matrices acting respectively on the gauge group and on the spin degrees of freedom.
Another way to write (1), summing over the index $i$ and using the $\delta_{ij}$ term, is:
$$ \tag{1'} \bar \psi_{\alpha, j} ( i \gamma^\mu_{\alpha \beta} \partial_\mu - m \delta_{\alpha \beta}) \psi_{\beta,j} = 0. $$
The physical reason for the kinetic operator $(i \! \not\! \partial-m) $ to be diagonal on the flavour indices is that during propagation the flavour does not change (e.g. a quark down does not decide by itself to become a bottom, if not interacting with something else).
Yet another way to write (1), with which you may or may not be more familiar is
$$ \tag{1''} i \bar \psi_\alpha^j \gamma^\mu_{\alpha\beta} \partial_\mu \psi_\beta^j
 - m \bar \psi_{\alpha}^j \psi_{\alpha}^j
\equiv i \bar \psi \gamma^\mu \partial_\mu \psi - m \bar \psi \psi = 0. $$

Expliciting the indices the gauge transformation has the form:
$$ \tag{2} \psi_{\alpha,i}(x)
\rightarrow (e^{ i g_s \alpha^a(x) T^a} )_{ij} \psi_{\alpha,j}(x),$$
which keeping only terms linear in $\alpha$ becomes:
$$ \tag{3} \psi_{\alpha,i}(x) \rightarrow ( \delta_{ij} + ig_s \alpha^a(x) T^a_{ij}) \psi_{\alpha,j}(x)
\equiv \psi_{\alpha,i}(x) + ig_s \alpha^a(x) T^a_{ij} \psi_{\alpha,j}(x),  $$
where it is important to notice how the generators $T^a$ act on the flavour indices $i,j$, not on the spinor indices $\alpha,\beta$.
Once you have made explicit all the sum involved in the indices, all the object you are left with are (eventually complex) numbers, hence they all commute (with the exception of the spinor fields of course, which are Grassman numbers.
How does this apply to your calculation?


*

*Your fourth term is neglected because of order $\mathcal{O}(\alpha^2)$.

*In your second term the derivative acts both on $\alpha$ and on $\psi$, giving the term (I'm no longer expliciting indices here for brevity):
$$ \tag{4} \bar \psi ( i \gamma^\mu \partial_\mu - m) ig_s \alpha^a T^a \psi
= -g_s (\partial_\mu \alpha^a) \bar \psi \gamma^\mu T^a \psi
+ i g_s \alpha^a \bar \psi ( i \gamma^\mu \partial_\mu - m ) T^a \psi  $$

*The term involving both the $\gamma$ and the generators $T^a$ (and the derivative $\partial_\mu$ acting on $\psi$) has the form:
$$ \tag{5} (i)^2g \alpha^a \bar \psi_{\alpha,i} (\gamma^\mu_{\alpha\beta} T^a_{ij} - T^a_{ij} \gamma^\mu_{\alpha\beta}) \partial_\mu \psi_{\beta,j} = 0, $$
where as I said above $\gamma^\mu_{\alpha\beta}, T^a_{ij} \in \mathbb{C}$ hence they commute.


See also the wikipedia article on the gauge covariant derivative for similar calculations.
