Cohomology and Eilenberg-MacLane spaces

It is well known that for any abelian group $$G$$, and any CW-complex $$X$$, the set $$[X, K(G,n)]$$ of homotopy classes of maps from $$X$$ to $$K(G,n)$$ is in natural bijection with the $$n^{\mathrm{th}}$$ singular cohomology group $$H^n(X; G)$$ with coefficients in $$G$$.

My question is, is there a similar bijection if the group is nonabelian? Notice that we only need to consider $$[X, K(G,1)]$$. In particular, I am trying to figure out what $$[X, K(G,1)]$$ looks like if $$G$$ is a finite group.

Assume $$X$$ connected.
Yes, this is known. For pointed homotopy classes this is $$\text{Hom}(\pi_1 X, G)$$. This is 1B.9 of Hatcher, usually the first place one sees obstruction theory, and requires less work than the case of $$n > 1$$.
For unpointed homotopy classes of maps, one quotients by conjugacy of elements of $$G$$. As you point out in the comments below, this is 4A.2 of Hatcher.
• What does it mean by "quotients by conjugacy of $\pi_1 X$ and $G$? From Hatcher's book 4A.2, we only need to quotient the pointed homotopy by $G$. – Totoro Feb 10 at 20:39
• @Totoro Here was the thought process (though you are right). In what follows I probably have some handedness wrong of my actions. Both $H$ and $G$ act on $\text{Hom}(H, G)$: let $$(h \cdot \rho \cdot g)(h') = g^{-1} \rho(h h' h^{-1}) g.$$ This is a new homomorphism and one can modify the homomorphism by either of these actions following an unbased homotopy. But because $\rho$ is a homomorphism, this is the same as conjugating by $\rho(h^{-1})g$, and hence the quotient by $H$ may be subsumed into the quotient by $G$. – user98602 Feb 10 at 20:58