This is not an answer. This is in response to Mike Miller's comment.

Let $M$ be a manifold, $\tilde{M}$ to be its associated universal cover (a simply connected covering space over $M$). I do not understand why they are not assuming $M$ to be connected. I am assuming $M$ is a connected manifold.

The following result is from the book Differential Geometry - Bundles, Connections, Metrics and Curvature by Clifford Henry Taubes.

Theorem $13.2$ (classification theorem for flat connections) says that, there is a bijection between the sets $\mathcal{F}_{M,G}$ and the set $\text{Hom}(\pi_1(M),G)/G$ where,

- $\mathcal{F}_{M,G}$ denote the set of equivalence classes of pairs $(P,A)$, where $P\rightarrow M$ is a principal $G$ bundle, and $A$ is a flat connection on $P(M,G)$. Two pairs $(P,A)$ and $(P',A')$ are equivalent, if there is an isomorphism of principal $G$-bundles $(\varphi,1_M):(P,M)\rightarrow (P',M)$ such that $\varphi^*A'=A$ (pullback of connection $A'$ is the connection $A$).
- $\text{Hom}(\pi_1(M),G)/G$ denote the set of equivalence classes of group homomorphisms $\pi_1(M)\rightarrow G$. Two morphisms $f_1:\pi_1(M)\rightarrow G$ and $f_2:\pi_1(M)\rightarrow G$ are equivalent if there exists $g\in G$ such that $f_1=gf_2g^{-1}:\pi_1(M)\rightarrow G$.

The bijection $\mathcal{F}_{M,G}\rightarrow \text{Hom}(\pi_1(M),G)/G$ is given as follows:

- given a principal bundle $P(M,G)$ with flat connection $A$, we get a group homomorphism $\pi(M)\rightarrow G$. Its equivalence class gives an element in $\text{Hom}(\pi_1(M),G)/G$.
- Let $\rho:\pi_1(M)\rightarrow G$ be a representative of an element in $\text{Hom}(\pi_1(M),G)/G$. Consider the trivial principal $G$-bundle $\tilde{M}\times G\rightarrow \tilde{M}$. The map $\rho:\pi_1(M)\rightarrow G$ given an action of $\pi_1(M)$ on $G$, which in turn gives an action of $\pi_1(M)$ on $\tilde{M}\times G$. Thus, trivial principal bundle $\tilde{M}\times G\rightarrow \tilde{M}$ induce
$(\tilde{M}\times G)/\pi_1(M)\rightarrow M$. Thus, we get a principal $G$-bundle over $M$, which we denote by $\tilde{M}\times_{\rho}G\rightarrow M$. It turns out that, there exists a $\mathfrak{g}$-valued $1$-form on $\tilde{M}\times_{\rho}G\rightarrow M$ whose pullback to $\tilde{M}\times G\rightarrow \tilde{M}$ is the canonical connection on the trivial bundle. It turns out that this $\mathfrak{g}$-valued $1$-form on $\tilde{M}\times_{\rho}G\rightarrow M$ is a flat connection on the principal bundle $\tilde{M}\times_{\rho}G\rightarrow M$. Thus, we get a principal bundle $(P_\rho,A_{\rho})$. Take its equivalence class to get an element in $\mathcal{F}_{M,G}$.

It is not clear how does this answer the question:

Given a principal bundle $P\rightarrow M$, how does one know for what
$\rho:\pi_1(M)\rightarrow G$, do we get that that there is an
isomorphism of principal bundle $P\cong \tilde{M}\times_{\rho}G$?

I am also interested in only "different" connections in the sense if two connections on $(P,M)$ are related by an isomorphism, in the sense of pullbacks, then I am calling these to be same.