How many colors really are there in QCD? In abelian gauge theory (electrodynamics), the matter fields transform like (please correct me if I am wrong)
$$
|\psi\rangle\rightarrow e^{in\theta(x)}|\psi\rangle\tag{1}
$$
under a gauge transformation, where e=1. In other words, they are a representation of the $\mathrm U(1)$ gauge group, which is always one-dimensional, but parameterized by an integer $n$, which is the electric charge of this state. To say this again, the charge is determined by the transformation property under the gauge group.
Similarly, in non-abelian gauge theory, matter transforms like
$$
|\psi\rangle\rightarrow e^{iT_a\alpha_a(x)}|\psi\rangle\tag{2}
$$
Here $a$ is the color index which runs from $0$ to $N^2-1$, for an $\mathrm{SU}(N)$ Yang-Mills theory, or in other words the dimension of the $\mathfrak{su}(N)$ Lie algebra. Obviously, this does not depend on the representation. My question is, if $n$ is viewed as the electric charge in (1), then why aren't all of the $T_a$ called "color charges" in Yang-Mills? Normally we say that there are three color charges, "red, green and blue", but from (2) it looks like there should actually be 8 of them, no matter what representation the quarks are transforming under!
I am knowing that the fundamental quarks are labelled by three numbers and adjoint matter eight. But these numbers do not appear in their gauge transformation rule, whereas for an electrically charged particle, the electrical charge does!! This makes me think that maybe electric and color charge are not exact analogues...
Am I going wrong here? Is it because "color charge" is not really the exact analogue of "electric charge" in non-abelian gauge theory? I mean, the electric charge labels the representation of U(1) on matter, but the color charge does not seem to label the representation of SU(N) on matter!
 A: Color charge is a general term that describes how a particle transforms under $SU(3)$ transformations, i.e. what is its $SU(3)$ representation.
The terms red, green and blue refer to the fundamental or defining representation of $SU(3)$ which is 3 dimensional. Red, green and blue refer to the three basis vectors in this representation, denoted by $| r \rangle$, $| g \rangle$, $| b \rangle$. This is the representation in which the quarks live so we can assign a red, green or blue color to quarks.
Gluons live in the adjoint representation which is 8 dimensional. We do not introduce a "new" color system for the adjoint representation because there is a wonderful property which allows you to construct the 8 basis vectors of the adjoint representation using the 3 red, green and blue colors of the fundamental representation. We exploit the amazing property (which holds for $SU(N)$ in general),
$$
F \otimes {\bar F} = A \oplus 1  \tag{1}
$$
which states that the tensor product of the fundamental and the anti-fundamental (conjugate fundamental) representation decomposes into the adjoint representation and the trivial representation.
More precisely, the 9 basis vectors on the LHS of (1) are
\begin{align}
| r \rangle | {\bar r} \rangle , | r \rangle | {\bar g} \rangle , | r \rangle | {\bar b} \rangle  \\
| g \rangle | {\bar r} \rangle , | g \rangle | {\bar g} \rangle , | g \rangle | {\bar b} \rangle  \\
| b \rangle | {\bar r} \rangle , | b \rangle | {\bar g} \rangle , | b \rangle | {\bar b} \rangle  \\
\end{align}
The adjoint representation is obtained from this by removing the singlet (trivial) representation from the above which we can do by setting
$$
| r \rangle | {\bar r} \rangle + | g \rangle | {\bar g} \rangle + | b \rangle | {\bar b} \rangle  = 0 . 
$$
This gives the total of 8 basis states in the adjoint representation. This is the representation in which the gluon lives so there are 8 gluons. However, as I said, we do not introduce 8 new colors to describe these gluons since we can simply combine the 3 fundamental colors red, green and blue.

EDIT - Let me also explain the difference between the $U(1)$ case and the $SU(3)$ case. $U(1)$ is an Abelian group so all of its representations are one-dimensional. To label the representation (aka electromagnetic charge) you therefore need just one number, $n$. Further since $U(1)$ is a compact group, we must also have $n \in {\mathbb Z}$.
On the other hand, $SU(3)$ is a non-abelian group so it has many $k$ dimensional representations for $k > 1$. Given an $k$ dimensional representation, states in that representation are labelled by $k$ numbers, $a_1,\cdots,a_k$.
A quark lives in the 3 dimensional fundamental representation so in general, we need 3 numbers to represent its state. In general a quark state is of the form
$$
| q \rangle = a_1 | r \rangle + a_2 | g \rangle + a_3 | b \rangle
$$
When we say a quark is red, we mean it has labels $(a_1,a_2,a_3) = (1,0,0)$. Of course, a quark in general can be in any superposition of states.
A gluon is in the 8 dimensional adjoint representation so it is labelled in general by 8 numbers

EDIT 2: It looks like I have misunderstood OP's question. It seems they meant to ask the similarity (or difference) between the abelian and the non-abelian transformation laws.
In the Abelian case, the transformation law is
$$
\psi \to e^{ i \theta   n } \psi 
$$
Here, $\theta$ labels the parameter for the transformation and $n$ labels the representation under which $\psi$ transforms (aka its electric charge).
In the non-Abelian case, the transformation law is
$$
\psi \to e^{ i \theta^a T^a } \psi
$$
Here $\theta^a$ are the parameters for the transformation (analogous to $\theta$ in the $U(1)$ case) and the generators $T^a$ are the generators in the representation under which $\psi$ transforms (analogous to $n$ in the $U(1)$ case).
As an example, if the group is $SU(2)$ then

*

*If $\psi$ transforms in the trivial representation, then $T^a = 0$.


*If $\psi$ transforms in the fundamental representation, then $T^a = \frac{1}{2} \sigma^a$ where $\sigma^a$ are the Pauli matrices.


*If $\psi$ transforms in the adjoint representation, then
$$
T^1 = \left(
\begin{array}{ccc}
 0 & 0 & 0 \\
 0 & 0 & -i \\
 0 & i & 0 \\
\end{array}
\right) , \qquad T^2 = \left(
\begin{array}{ccc}
 0 & 0 & i \\
 0 & 0 & 0 \\
 -i & 0 & 0 \\
\end{array}
\right) , \qquad T^3 = \left(
\begin{array}{ccc}
 0 & -i & 0 \\
 i & 0 & 0 \\
 0 & 0 & 0 \\
\end{array}
\right) . 
$$
One can similarly write down all the matrices for $SU(3)$ as well but it's longer so I won't bother here (see here).
To make my point once again - the ``charge'' of any particle always corresponds to its representation under the symmetry group. For the $U(1)$ group, representations are labelled by one integer $n$ so we call $n$ the electric charge. In the non-Abelian case, representations are not labelled by just one integer so the labelling is not so simple. In this case, we simply give a name to the representation. Using this language, we would say that the color charge of a quark is "fundamental" and the color charge of a gluon is "adjoint".
Within a representation, there are many states! Again, in $U(1)$ case representations are one-dimensional, so each representation contains just ONE (unique) state. Therefore, apart from the integer $n$ no other information is required to describe this state.
In the non-abelian case, representations are higher dimensional, so in order to describe the state of the particle, one needs more information than just its representation - we need to specify the exact vector. So the color charge of a quark is "fundamental" and its color charge state can be red, green, or blue (or superposition thereof).
